Exporting Access data to pre-existing and pre-formatted Excel spreadsheets - excel

Good day all,
I am very new to Access and VBA, so some of these questions may seem elementary, but any help offered would be greatly appreciated... I am a member of a recruiting organization, and am trying to build a database system that will greatly increase our administrative efficiency and quality of life. My organization insists on the use of Excel spreadsheets that are supplied to us to document our efforts and for our reports, thus ruling out the possibility of using the reports from Access. I have the underlying database pretty well ironed out, but what I need help with is taking that data and putting it in specific cells within an existing excel spreadsheet. Specifically, what steps do I need to tell access to do, how to select the appropriate worksheet, and how to select individual cells to send data to. I also need to link all of this to a button on a form labeled, say, "Generate Applicant Log"... Additionally, I would like both the database and all applicable template spreadsheets we would need to be located in the same folder that I can lock, so that I can send the whole folder to another user and all necessary files are included, but they can't get into the folder to mess with stuff. I am concerned this will affect whatever coding I would use due to the changing file path names from user to user, so any help in figuring out a way to tell access how to find the spreadsheets relative to where the database is so it always works no matter who's computer the folder is on or where it is at in the same computer, would also be greatly appreciated... I apologize in advance for the length of this inquiry, and graciously appreciate any help in this matter! Thank you for your time!

Rather than send data from Access to Excel, it is easier to pull data into Excel from Access. In Excel, on the "Data" tab select "from other sources" and build a Microsoft Query. I like to put the data into a spreadsheet and link the data into the sheet the user will see - I hide the original sheet. This way you can put all of the data into the hidden sheet, and then move things for the reports you need.
Using this method, I bring measurement data from a database, show it to users that need to review it, and run VBA routines to evaluate the data and highlight the interesting / important data. I also keep the users out of the original database.
I have my database on a server and I cannot offer help on sending the database and files to the user. I just send the file - they have access to the server and the data is refreshed each time the spreadsheet opens.

Related

Vba code in original file to track all copied files

Is it possible to insert a code so we can track all copied excel files in the future?
The reason why: we are creating a template excel file that people can copy and fill in. The problem is that they regularly have to fill in the same information so instead of starting from the template they copy the already filled in template.
If we decide to change the template, we want to change all the files that were copied so there are no multiple versions going around.
All the files are stored on a server in subfolders so We can access them all. Titles of the file will vary based on the wishes from the customer.
After reading you, I see that:
Summary:
You have one single Template that everybody copies
You store all the filled templates on one Server Subfolder
Title of the Files varies from Customer's needs
Challenges:
For Performance shake, you might need of a program than Excel to manage those files
Otherwise, it is possible to use Excel VBA, but is somehow/enough complicated so you would need to have an advanced skills and enough time to write everything handling that Subfolders' file renaming if you wish to collect the data in one Single Excel.
Suggested Solution:
I recommend you to have A Locked Worksheet + Workbook Excel
Template so your customers won't be able to edit its structure and
it will keep all of your templates to be the same.
You better have some kind of the Standard in the nomenclature of your Excel Files which will help you use that description later on for search/filter/sorting ...
You can have a Reset Button as well within the Template where your customers will click and will empty all the fields effortless.
In short, If you wish to track of files being copies, you would need more than Excel VBA for that as you need to play with A windows service for you to track them.
Hope this will give you some ideas. All the Best!

Add data into access records via Excel import

Hello and thanks for any help. I'm a noob with Access but my company has asked a question about possibly importing some information for certain records in Access. Basically, I work for an insurance company and they have a claims system which was built in Access about a decade ago by someone who has left the company recently. The system works and is fine for current needs. However, we were recently asked to amend a field for certain records (claims). Because there are about 200-300 records, we are looking at a possible import solution.
The problem is, I have never done this before and am worried that it might affect other records or other fields in the records. The only thing that needs to change is one field and the rest must remain unchanged.
I know the Access table name & record numbers (RecordNo - textbox in Access) and the name of the field I want to change (Reference - textbox in Access) but am unsure how this can be imported, how the excel file needs to be prepared and how to make sure no new records are added but instead existing records are amended.
For instance, can I just have 2 columns, one called "RecordNo" and the other "Reference"? Or do I need to add blank columns to account for the extra columns in the Access table? Do I need to create a named range or an excel table or simply put the columns in Excel? Is there any specific formatting that I should be using (Text or General or something else - the Reference will be a text value as it has both numbers and letters)? When importing in Access using the import wizard, do I need to choose "Append a copy of the records to the table"? How will it know which record to amend as the Access table will contain thousands of records that I don't want changed in any way?
I also have access to the "Navigation Pane" in Access where I can find tables and queries etc and not sure if the records in question can be bulk amended on the table instead?
To make matters more complicated, the Access database is on the server and needs to be accessed by multiple users at the same time so I would ideally like to test this out on a separate copy. But copying it to my own computer does not sever the connection with the copy on the server and any changes are reflected in the original copy immediately.
I tried looking online but I can't seem to find anything that will quash my worries. I can find a few articles talking about importing issues, though not what I would be interested in, but they are all for previous versions of Access and really I can barely understand the current version. We are using Excel and Access 2013.
If possible, I would rather not use VBA as the current database has a lot of it anyway and its's difficult to manage and navigate. I also have no idea about Access VBA, just excel.
Thank you
To make matters more complicated, the Access database is on the server
and needs to be accessed by multiple users at the same time so I would
ideally like to test this out on a separate copy. But copying it to my
own computer does not sever the connection with the copy on the server
and any changes are reflected in the original copy immediately
That is because you are only copying the front end. There is somewhere a separate access file that is the back end. Or it could be a different database system like MS SQL Server or MySQL. So your first task it to find where the actual data is.
Beyond that, under no circumstances import an excel file directly into an existing table. Create an excel file with the necessary fields (record identifier and new value) and import it as a new table, then create an update query to effect the changes you need.

developing a front end app using excel spread sheets

We get at least 20 queries a day on an average from our clients, where in we have to open and look at data on 4 to 5 Excel sheets to answer them. questions such as what is my available balance, am i eligible for this etc. All our clients are connected to our intranet and have access to internet. I was wondering is there a way where we can develop a front end app (do not have budget for MS VB or any other) either in excel or any other to connect these 4 to 5 excel sheets to retrieve the data in response to queries (e.g. using perhaps some if and true/false queries). I am not an advanced Excel user but would be great for an advice from tech experts.
Yes, i wouldn't call it an app but consider a worksheet like a dashboard. You can have a cell for entering client name, and then use formulas to look up relevant information of the name entered. The cosmetic and arrangement of the information retrieved and published on the dashboard is up to you and of course do consider investing some time in the looks and feel if you want to enjoy using it.
Things you may consider are:
Place the files are kept and file name convention
because your dashboard will look for information in external workbooks, ensure that the files are saved in a fixed directory and have a specific file name. if the external files are updated from time to time by other folks, let them know too that they have to save it in a particular folder with a specific name format.
Properly structure the source of data
Format you data source into tables so that it is easier for use with formulas. Throw away titles if any in the data source worksheet. Use tools like "Table" under the INSERT tab. When data are properly organized, they can be easily looked up using formulas such as VLOOKUP, SUMIFS, MATCH-INDEX, and COUNTIF.
Be good with formulas
Since we have no budget for VB, then good formulas will be needed. There are plenty of help on the internet for this I think you'll have no problem in it.
Employ sanitary check measure
It is difficult to tell if our formula isn't functioning properly when we have no counter check measure. Certainly you want to give your clients accurate information. One way to check is, think of alternative ways to get the information wanted and check if it matches to the first way. Another way is to retrieve a sequence of related information to be put on the dashboard, then do simple calculation to check if the numbers add up. Use conditional formatting to highlight errors if necessary.
I think these are key consideration, there may be more, but this is what i can think of for the moment.

Storing Collections through VBA in Access

In my Access 2013 Desktop database, I want to validate an Excel form through VBA before importing its rows to a table.
The problem is that the imported Excel table may contain in the same column values that are numeric, string, null, etc. depending on the row due to mistakes from the user, so these values have to be initially of VBA type Variant before validation.
If the row is invalid (e.g. one value is not of numeric type while it should be, one mandatory field is null, etc.), I want to be able to store its values and let the user correct it later on. I am therefore looking for a way to build a table where I could store these rows, but where the fields are kept intact, so with the possible mixed data types.
This seems not to be possible, as Access tables need apparently to have fields of a defined type, so nothing equivalent to Variant.
How could I achieve this? What would be the simplest and most efficient way to store rows of Variant values while keeping the structure of the columns? The only way I could think of so far is to concatenate these values for each row in a string using some defined separator, and store this in a String column in an Access table, but maybe there is an easier way to do?
Thanks a lot for your help.
EDIT: Reading your answers I realized that I forgot to specify that the people filling and sending the Excel forms (who typically do not have Access on their computers) are not the same users than the ones who have the Access database and need to import the data. In this configuration it is impossible to use directly Access forms to input data, which would of course simplify tremendously the task. While we try to enforce rules for people who fill the Excel form at the first place there will be mistakes and the Access application needs to cope with them. And the importing process for the users manipulating Access should be as simple as possible (these users are not experts in IT).
I though about your problem for a while and made a few notes as I thought below.
I would strongly advise that unless the excel workbook is providing other functionality that you do not use excel, but create an simple Access database with a form they can use to interact with "their" data. They do not necessarily need an Access license to do this. Access 2013 even has new web features that can be used if you have sharepoint to collect data via a Access created web frontend.
If you are to collect data in Excel, then you must use excel validation and VBA code to validate the data as much as possible before transferring to access.
There are complexities that may or may not be an issue for you, things like:
Can users edit/created/delete the same rows concurrently - what happens if they do! You may need to "lock" rows when they are downloaded from Access. But what happens if tow users add the same record, or ones deletes a row before another user commits it back again.
Can a user open multiple excel files and edit the data they store without committing the data to Access?
Can multiple users login to the same Workbook with uncommitted changes and edit the data.
Using access will simplify your code as it will be able to prevent erroneous data being entered and remove the need to deal with the above issues and others
In summary you are using excel as a front end "form" to data stored in Access.
Each excel file can have data that has yet to be up
I would suggest that the primary key of a row is the "path and name" of the excel file that was used to create it & a unique numeric identifier. The unique identifier is a counter that is maintained for each excel file. The "path and filename" could be replaced by a unique identifier created for each file.
Many users enter data using multiple instances of Excel into a form which results in one or more rows being updated/inserted/deleted in an Excel table stored in each spreadsheet.
I would expect that whenever Excel is opened the user enters a username and excel will grab "their data" from Access. Alternatively a workbook might be set up for each department or "case type" and only interact with data that matches this "custom criteria set up in the workbook". Excel would not necessarily need to store data itself longterm. The workbook might always save data back to the database when it is saved.
You say Excel VBA performs limited validation on the data (but no complete validation). It should be used as much as possible and arguably should be able to do exactly the same validation that access can do. At the very least it should enforce datatypes etc (eg using the standard data validation rules on the excel data menu) or perhaps use VBA/controls to get any access data it needs to validate the data entered.
After updating the data the user can "commit" (ie save) the data to the access database. Before closing the workbook you might want to commit the data.
(An issue is whether a user might open many workbooks perhaps on many machines without committing the data.)
An Access "staging" table can be created with all columns having the datatype "shorttext" and not-required.
The process that loads data from an excel table into Access, will uploaded all excel rows into this staging table. It will then validate each row in the staging table and process all valid data into the main table(s) that have data types, relationships constraints etc.. Any valid rows in the staging table are flagged as "VALIDATED & TRANSFERRED", Invalid rows are flagged as INVALID. The "VALIDATED AND TRANSFERRED ROWS" are subsequently ignored, but kept so you can check what processing has happened, perhaps only whilst testing.
The data in excel is then updated with the Valid/Invalid status from Access and suitable messages given to the excel user. The user may correct and then re-commit the data.
Each excel file has a status of "changed/Unchanged" to indicate whether a user has changed data in the file.
When a user opens an excel workbook and status is unchanged it will refresh it's data. If it's changed a refresh probably can't be done.
In order for the data in Access to be updated/deleted/inserted with the changes made in Excel, there will need to be a unique identifier for each row that cannot be changed by the users in excel. This is likely to be the Path&Filename or the UserName logged into Excel and a numeric counter (which is maintained for each file or user). (This assumes that the user will have to commit changes in one excel file before they work on another.)
Anyway, without knowing more it's difficult to fully design what you will need, but I hope these thoughts help you
Harvey

Can you pull data from a spreadsheet that is security protected?

If our finance department wants us to create a web app that pulls data from a spreadsheet calculation, based on user input, but also want that spreadsheet to be private from all developers working on the app, is this possible?
How do companies launch an app with sensitive information that they want to protect?
Can you access data from an excel spreadsheet that is security protected?
Easiest way to develop such an application (this is a high level answer of "how do develop an app when you can't see the classified or protected data" not "how do i make a web portal with an excel backend") is to get "dummy" data.
You make the dummy data just as protected, but give the developers the ability to see the data on the other side of the wall. You make sure the datatypes are the same (the only thing different should be values) and go from there. That's the easy way. After the app is developed with the dummy data, it's deployed and people with access to the data "connect the pipes" and away you go.
As to using an excel sheet as a backend to a website..please look into MySQL or MSSQL or some other database solution. The developer coming after you will thank you.
If you can't because of management..ripping open an excel file directly is not for the faint of heart, but microsoft does provide an api to access the insides. I've done it once..and don't remember how to off the top of my head, but perhaps someone more skilled remembers the api. The easier road is to have that workbook output to CSV (which is easily parsed).
I would recommend the excel workbook update a table that you apply whatever security scheme you need to on. Also you can put the workbook in a location that only those with proper rights can access.
If the user input is limited to a a field or two and the values are for easily determined values that doesn't span a huge range, then create a lookup table. In this table, you would store the results for all possible combinations of input values. This would allow for you to not putting the Excel spreadsheet on the Web server.

Resources