Macro For MS Access for Batch Uploading - ms-access

I want to upload 1000 CSV file to a single table in MSAccess. Could someone help me with macro for that.

First make sure your CSV is fit to upload - no blank lines, no blank colums, column headers worded to suit Access (No spaces, no Reserved words, no barred characters). Then in the access ribbon click External data, select the file type you are importing, then browse to the file and create a new table. You will have to help access with the data types during the import process.

Related

How to remove spaces from field names when importing external data into MS Access 2010

I have an external file that I don't create which I need to import on a rolling basis, most of the column headers/field names have spaces in them. Is there a query I can write to change all of them at once? I'd rather not write a long query to get rid of spaces for each individual field name. The field names are always the same and in the same order in the file, the spaces are in the middle of the field names (ex: "Employee Number").
First of all, "query" refers to an SQL statement (including those viewed in Design View) that retrieve or act on data already in the database. Importing data from an external file is a separate action, not generally called a query. So strictly speaking the answer is "no".
However, Access does have built-in import functionality in Access. I suppose you can call these import "functions" or "actions" or "processes", just not queries. And I'm not being a smart aleck, since much of getting help with applications and code is learning and using the correct terms.
Go to the External Data ribbon (a.k.a. toolbar) along the top of Access.
Click the Import Text File icon (careful not to click the Export Text File icon, since they look similar. Hover the mouse cursor over each button to see the text description of it).
Choose the filename, and pick which import option
As Gustav instructs in his answer, choosing "Link to data source by creating a linked table" is the most efficient solution for external files that don't change format. The linked table (hence the external file) can be re-queried without repeating numerous steps.
Walk through the Import Wizard steps. Play with the options if you need to figure it all out.
In particular, make sure to check "First Row Contains Field Names"
On one of the wizard steps, you can edit the field names to remove the spaces.
On the last step, click the "Save Import Steps" checkbox, specify a name, then click the "Save Import" button
To re-use the previously-saved import steps:
Go to the External Data ribbon (a.k.a. toolbar) along the top of Access.
Click "Saved Imports" button
Choose your saved import settings
Click Run
OR if you created a Linked table
There is no need to "re-import". Instead, a normal Access query can be used to get the data and update one of your normal data tables.
If the path of the external files changes, this can also be updated by right-clicking the linked table and choosing Linked Table Manager (also available on the External Data ribbon). Select the table in the list and also check "Always prompt for new location" before clicking OK. A standard file selection dialogue will be shown for selecting a new filepath.
(Just to be complete, it is also possible to write VBA code in Access to open a file, read and analyze the headers and then import the data according to your custom behavior, but this isn't for you if you'd "rather not write a long..." something to do this.)
I'd rather not write a long query to get rid of spaces for each individual field name.
Maybe not, but there is no smart way to overcome this.
However, don't import the file but link it. Then use the linked file as source in your query. In this, alias the field names as you prefer, and do basic filtering and conversion of data. Then use this query for your further processing.

Importing text file to Access database in Windows 7

I am trying to import data from a text file to Access 2007 and 2010, delimited by vertical bar. I use Import Text Wizard of MS Access, but when I try to import it after choosing appropriate delimiter (preview looks fine), I get the following error:
The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.
There are no primary keys, nor relationships, as it is just a text file. I was able to insert this text file in Windows XP, but the problem arises in Windows 7. I was able to successfully export the data into Excel. I also set Indexed to No in Field Options of Import Text Wizard, but that didn't help either.
Any help would be greatly appreciated, as I couldn't find any useful info anywhere.
Edit: I tried inserting into new and existing tables, even a new database (accdb and mdb format), every time I get the same error.
Edit2: I opened the text file in WordPad, and saved it again as txt file, the Access didn't generate any error. The previous txt file didn't show the new lines, but Access was still aware where each record ends, and preview looked fine. The new text file specifically shows new lines (each record separately). If someone has a suggestion about how to overcome this issue without creating a new txt file, please let me know
I don't think there is anything you can do except convert the file to Windows CRLF format.
Although I wouldn't use WordPad for this, but Notepad++.
It has an explicit command for this: Edit -> EOL conversion, and you can be fairly sure that it won't change anything else in your file (I wouldn't be so sure about WordPad).
Actually most text editors that are more sophisticated than Notepad have a command for this, I think. :)

Issues with Access parsing double quotes in a CSV file

I have a large CSV file that I am trying to import into Microsoft Access but I am running into issues. Assume pipes represent different cells in the database
Assume my content is the below. The second entry will only parse the word my with default settings and will not import the word content into the database even though the import wizard implies that it will. The default settings being , delimiter and " text qualifier.
|my content is good|
|my|
Now if i change the text qualifier to NONE it parses the entire second entry and my content will be imported into the database however the first entry will wind up being in 3 different cells in the data base and will show up as
my|content|is|good.
|my content
I used pipes to imply different cells.
This seems like a limitation in Microsoft Access. Is anyone familiar with a workaround for this?
Original content:
,"my,content,is,good","",
,my"content","",
I am using the import wizard
Yes, this is a limitation of the CSV import capabilities in Access. For whatever reason, Access has always been more restrictive than Excel in its abilities to parse CSV files.
So, one workaround would be to open the CSV file in Excel, save the file as an actual Excel sheet, and then import the Excel sheet into Access. For example, the CSV file
this,is,a "test",CSV file,"Ugly, yes, but still parsable."
is "non-standard" (if one is willing to concede that there is such a thing as a CSV "standard"), and Access cannot import it directly. (It either complains of an "Unparsable Record" or it splits the last field on the commas, depending on the "Text Qualifier" setting.)
However, we can open it in Excel
save the file as "foo.xlsx", and then import the .xlsx file into Access

CSV Load data not importing file

Importing CSV into MySQL by PHPmyAdmin using "CSV LOAD DATA".
The process does not throw any errors during the upload.
(I have made sure my columns are correct)
But as it returns the results, there are none.
Over 51000 rows of data in the spreadsheet, and "Browse" returns zero results.
Any suggestions? Maybe I am uploading too large of a spreadsheet?
All the fields need to be enclosed in quotes. Your best bet is to use an Excel file with a macro that does that for you. I wrote a tutorial on how to do just what you're describing which includes a link to an Excel file with a macro. Here's a link.

Updating an imported .csv in Hyperion v8.3

I have a csv imported into my Hyperion v8.3 bqy file. I have some custom columns and a pivot already created. I just want to refresh the data. In the past, I would hit Process Current and it would direct me to my computer and I could select the csv file to update from. Now it will not do that. It doesn't go to my computer at all.
Any ideas?
Eric,
I'm not a power user but I accomplish the same thing by ensuring that there is a file with the same name in the same location from which the original csv was imported and "Processing All". This allows me to update the data and import it into my bqy and automatically update any reporting based on the csv.
Don't know if this will help or not.
Dennis
dennis.van.camp#vanderlande.com
When you import a file as a Section into Hyperion, it maintains a link to the existing file for the exact path and file name. When that link is broken and that section gets a Process or Refresh command, is the only time it will prompt you for a new file. Otherwise, it will refresh the data from the existing.
So, if you want to force it to prompt you for a new file, you have to move or rename the old file.
But, you're looking for the Pivot and Computed columns to refresh. Two things on that ...
Computed Columns: You don't have to re-import the file, if the rest of your data is current. Each column can be refreshed individually by right-click, Modify, then clicking Ok. You don't have to change any of the code; just hit okay instead of Cancel.
Pivot: In the menu, you have to set your pivot options appropriately to update when you Process (when the underlying data is Processed, really), or Manually (when you Process that section).