Modules & VBA :: Importing CSV File Into Staging Table And Using Headings

Oct 6, 2014

I currently use the following to import a csv file into a staging table and then append and save the data to a table - however it doesnt use the headings from the csv file and creates an error table and a blank record where the headings should be apart from one column where it copies the name.

Would it be possible to use the headings as field names or just omit them completely and use the standard f1 f2 f3 etc access generates in the tmp table?

Code:
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Select the CSV file to import"
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "CSV Files", "*.csv", 1
.Filters.Add "All Files", "*.*", 2

[Code] ....

View Replies


ADVERTISEMENT

Modules & VBA :: Importing CSV File Into A Table

Feb 21, 2014

I am trying to import a csv file into a table... it works fine however it put all of the row in just one column ...

DoCmd.TransferText TransferType:=acImportDelim, TableName:="tblTempImport", _
Filename:=CurrentProject.Path & "/xxx.csv", HasFieldNames:=False

And i end up with tblTempImport only having one column F1....

View 14 Replies View Related

Modules & VBA :: Error 2391 When Importing Csv File Into Table?

Jan 29, 2015

I am importing csv files into tables in a batch routine and I get the following error messages. The error number is always 2391.

Field 'F1' Doesn't Exist in Destination Table
Field 'F4' Doesn't Exist in Destination Table
Field 'F36' Doesn't Exist in Destination Table

I understand the first one and can find references to this on the web but the F4 and F36 escape me.

All fields required do actually exist in the table so the real problem is elsewhere.

P.S. I now think that it may be that there are embedded commas in one or more of the text fields and that the number following the 'F' indicates the position of the field in the table. I will check in the morning or create the csv files using commas and quotes.

View 1 Replies View Related

Modules & VBA :: Importing Data From CSV File Into Access Table

Jul 19, 2013

Code beneath worked perfectly with Access 2003.Now we switched to Access 2010 and it generates a table where data isn't put into my 77 fields like before, but seperated into 1 field, separated by some ;;;.I am not good with programming.

Dim rst_data As Recordset
Dim oldname As String, newname As String
DoCmd.DeleteObject acTable, "TBL_import_TPXP_Radi_Evvd"
DoCmd.TransferText acImportDelim, , "TBL_import_TPXP_Radi_Evvd", "N:APPLSHAREPRDQSIGMKTDISTPWBUSPB1815RADIEV IMPACT.CSV", False, ""

[code]...

View 2 Replies View Related

Modules & VBA :: Access 2007 / Code For Bulk Importing TXT File Into Separate Records Same Table?

Jul 9, 2014

I have 12,000 cvs that i need to get into An access database so i can start to extract email info etc. They are stored in one folder All Cvs under each of their names edc.txt (i have converted them to .txt) i want to create one table with two fields name (taken from the cv filename and contents (taken fromthe contents of the .txt file). I am using Access 2007.

View 2 Replies View Related

Queries :: SELECT DISTINCT Not Removing Duplicate Records In Staging Table

Jan 29, 2015

I have a database with an import process which normalises incoming data and appends to various tables. No issues with that. I also have a function within that process which counts the number of new entries for a summary popup when the process has completed.This works by querying the staging table, prior to the append, into a recordset and using the .RecordCount to increment the count (multiple files can be imported at once so this effectively provides a running count, per file, to give a total for the whole import)

I thought it was working fine but this morning I noticed that the count which appeared on the popup was 1 greater than the number of actual new records. I checked the source files and noticed that, for whatever reason, there was a duplicate entry in there. So I presume that's why the count was out by 1.

There's no integrity issue in the main tables as the composite primary keys ensure that duplication shouldn't be a problem. Indeed, the record in question, duplicated in the source, appears only once in the main table post-import. So not too worried about that.

However, I need the count in the popup to be accurate (it tells the users how many new entries require further investugation). And what's puzzling me is that I use DISTINCT in the query, which I would have thought should eliminate any potential dupes in the recordset and thus provide the correct count. It seems it doesn't?

Code:
Public lngNewBalancesTBI As Long ' Defined in a separate module...
-------
Dim dbs As Database
Dim rst As Recordset
Dim strSQL As String

[code]....

Why the dupe, which is still present in the staging table, also makes it over to the recordset, even though I'm using DISTINCT?

View 14 Replies View Related

Modules & VBA :: Importing TXT File Run Time Error 424 Object Required

Jun 12, 2015

I am trying to create a txt file to import into our accounting software. I get the file (its blank), but it fails on the WriteLine and i get the run time error. I have a command button on a form that the user will click to export the file.

Private Sub cmdExport_Click()
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strPath As String
Dim strPathGB As String

[Code] ....

View 6 Replies View Related

A Tough One - Importing A File Into A NEW Table

May 25, 2006

I work for a company that has a mainframe application that produces "outgoing" files. They are downloaded to a server and converted to ASCII (all at one time) and then ftp'ed to various clients. We are converting to a client server application and I am in charge of verifying that the mainframe application files (converted) are EXACTLY the same as the server application files. I came up with a process of loading the files to access databases and then with a series of queries and reports produce a list of exactly what doesn't match, which record, what positions and display the two fields that are mismatching.

My problem is that when I try to load the Mainframe file (note that it has already been converted and "eyeball to eyeball" the files are alike) using the "new" / import functions, Access rejects the file because it is greater than 65000 bytes. If I cut the file down to under 65k bytes it loads fine. I can load a 500,000 byte file that was created on the server in the first place.

Any suggestions? I can't change any of the processes that create the files. But I can change copies of the files so that I might be able to get them to load so I can verify that the data inside is the same. I'll let the geeks figure out how to fix the file/record control stuff.

(wouldn't have this problem if I was back on a mainframe!!!!)

Mac

View 3 Replies View Related

Change Excel Headings Through Access VBA Then Import The File

Sep 17, 2014

I've been able to find the code I need to import the file, but there are headers that come through from the group sending the excel file that will not import - they have a "." in them and that won't work. I need to find a way to remove the character and bring the excel header in line with the access table I'm importing to. I'm using the following to import the file:

Sub Example()
'the path to the excel workbook
Dim strExcelPath As String
strExcelPath = "C: est est esting.xls"
'import data from excel
Call DoCmd.TransferSpreadsheet(acImport, _
acSpreadsheetTypeExcel8, "testtable", strExcelPath, _
True, "A1:AA11")
End Sub

And that work fine up until it hits the offending headers. what is a good, quick bit of code to plug in to alter the headers and what, if any references would need to be added?

View 1 Replies View Related

Importing Table From Text File - Complicated

Apr 10, 2007

Hello - I want to import a text file into a table in a database. The text file looks like this:

00001 06006025 1420 0010 Health Insurance 7
00001 06006025 1425 0010 Life Insurance 7
00001 06006025 1430 0010 Disability 7
00001 06006025 1440 0010 Profit Sharing 7

There is no consistent delimiter. The text field is making things complicated because there is no accurate way to separate the text field from the last number in each line ('7') which needs to be stored in a different column.

Is there a way to insert quotations arond the text string so the quotation mark can be used to distinguish it when importing into excel or a database table. This may work because the starting position of the text string is constant. The ending position would have to be defined as the place where the number appears ('7' in this case). Then, quotations need to be placed around the text string.

Is this possible? Any advice will help tons!!!

View 5 Replies View Related

Importing .txt File With Time Of Day Field Into Table

Mar 16, 2008

I'm able to do the import, but I can't get the time of day to show up in military format, which seems more useful when I'm wanting to filter out certain blocks of time later on.

The attached jpg shows the format of the source txt file. The time is shown as 09:30 AM for instance. The attached screen shot for the import text wizard doesn't mean much to me at this point, because no settings seem to work. I've also attached the Import Specification window.

What's been happening is I've been getting a table with field2 showing time in this format 09:30:00 AM where the AM is random and unreliable followed by field3 showing the correct AM/PM designation. This is when I just let all the text wizard stuff run by default settings.

I can then go into the table in design view and change the format of the time of day to hh:nn which gives me 09:30, but then I'm still stuck with the problem of converting all the figures in fields 2 and 3 into something I can work with. BTW, Hh:mm:ss defaults to hh:nn.

Would it be better perhaps to first convert my source file to another format such as csv?

View 3 Replies View Related

Importing A Text File Into Access Table

Jun 13, 2006

Hi,

I have a text file with comma separated values. What I want is a single access query to import this text file into an access table. I know this can be done through import text wizard in access - but what I need is a single query.
I have done the same thing for transferring oracle data to an access table - but for text file to access, I am getting -7778 error.

This is the query I have written
SELECT * into MY_ACCESS_TBL from [odbc;Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=MY_TEXT_FILE_PATH;].[MY_TEXT_FILE.txt];

Please help!!

Regards,
Suneesh

View 7 Replies View Related

Importing Excel File To Append A Table

Jun 27, 2012

Is the record is already existing in access, but a few fields are blank, is there any way to import an excel file that just updates those blank fields for the specific record?

For example,

I have an excel file that includes files that are ready to ship out. My access database already has those file names, but does not have the shipping box number. Is there any way to import the excel file into my database, have it find those specific file names and update the shipping box number field? The excel file won't be adding any new records, just appending existing records.

View 1 Replies View Related

Importing Data From Dat File To Append To A Table?

Nov 30, 2012

I'd like to be able to filter through a .dat file like that (which is pretty much just like a .txt file as far as I can tell) and have that data appended into a table by way of a command button.

The annoying thing is that the data would have to be pulled out of the .dat file by position into columns like this:

Example line:

Code:
09 19192 00010212b1 5010570223
19192 = Ticket (Will be 5 digits long)
0001 = Quantity (Should be 4 digits long)
0212b1 - Location (Will be 6 characters long)
5010570223 = Article (Will be 10 characters long (not numbers))

by the way, let's say the .dat file will be in folder C:CENTURYWTERM.

View 5 Replies View Related

VBA Code For Importing Tab-delimited Text File Into A Table In Ms Access

Aug 25, 2004

Hi

I need to create a command button to import a tab delimited text file into a table in Microsoft Access using VBA Code.

I have set up the button however I am unsure as to how I should approach it and what code i need.
If anybody has any suggestions I would be very grateful.

Kind Regards

Elaine

View 1 Replies View Related

Table Headings

May 16, 2006

Hello
Im new to access and really need some help please.

I have a table with column headings i need to split up but dont know how to write it in code.

i want to split AA: Austrailia 1-3Years into AA and 1-3

i then want to compare both those string to another table and allocate a number in a further table. does that make sense?
please help!
many thanks

View 4 Replies View Related

Modules & VBA :: Importing A Table Without Knowing Its Name?

Aug 13, 2013

how to import a table using VBA like so:

Code:
Private Sub Command0_Click()
Dim dr As String
dr = Dir("F:SomeFolder*.mdb", vbDirectory)
DoCmd.TransferDatabase acImport, "Microsoft Access", "F:SomeFolder" & dr, acTable, "Table", "Table2"
End Sub

This was just a test to see if I could get an import to work. My problem is that I have a lot of .mdb/.accdb files with similar tables that I need to add into one larger database and these similar tables could have different names in different folders. For example, a file named db1.mdb has a table named tbl. Another file named db2.mdb has a table with all of the same fields, but its called tabX. Furthermore, db2.mdb could even contain a second table that I need to import.

My question is:

Is there a way to simply import all the tables from an access database without knowing any table names using VBA?

View 5 Replies View Related

Modules & VBA :: Importing / Parsing From PDF Into Table

Aug 27, 2014

We publish a PDF file every week full of taskings that our subordinate organizations need to accomplish for the following week. I would like to have parse the PDF and store the data in a table. I think the only way to start this operation is to first save the PDF to Text (Plain) as this create some way to delimit and parse the data. So, once it's saved as a txt file, it basically looks something like this:

Code:
//
Column 1 Data/StuffIDontCareAbout/
StuffIDontCareAbout/StuffIDontCareAbout//Column 2 Data
StuffIDontCareAbout/StuffIDontCareAbout/
Column 3 Data

[Code] ....

...and so on and so forth anywhere between 50-100 more times

The entire text file will always start and end with "//" at the top and bottom. You also see that each tasking paragraph (starting with "Column 1 Data" and ending with "Column 3 Data") is preceded by a "//" on its own line, and also followed by a "//" on its own line. The text file will always look exactly like this with each tasking paragraph having the same number of forward slashes.

Column 1 Data always starts on a new line under "//" and runs until the first "/" (single forward slash).
Column 2 Data always starts after the "//" on the 2nd paragraph line and runs until the end of the paragraph line
Column 3 Data always starts on the 4th paragraph line and runs until the end of the paragraph line

Here's a quick example of what I'm talking about:

Code:
//
37 NOS001/DCO/
TaskPer/TBD//310001ZAUG2014-292359ZSEP2014
GenText/Remarks/
(U/FOUO) This will contain the actual task description and details. You can see that "(U/FOUO)" contains a forward slash.

[Code] ....

So after it's parsed, my table would have the following new rows:

Code:
Column 1 | Column 2 | Column 3
37 NOS001 |310001ZAUG2014-292|(U/FOUO) This will contain
582 NOS012 |280001ZAUG2014-022|(U/FOUO) This another task

View 3 Replies View Related

Modules & VBA :: Copy Results Of Query Without Headings To Clipboard

May 19, 2014

I found the following code to copy the results of a query to the clipboard.

Code:
DoCmd.OpenQuery "DataLoadTemp_qry", acViewNormal, acEdit
DoCmd.SelectObject acQuery, "DataLoadTemp_qry"
DoCmd.RunCommand acCmdSelectAllRecords
RunCommand acCmdCopy
DoCmd.Close acQuery, "DataLoadTemp_qry", acSaveNo

It works great, except that it is also copying the column headings. Is there any way to copy only the results without the headings?

I'm copying this data to the clipboard because I want to be able to paste it in a program called DataLoad which will load this data into one of our company's legacy systems.

View 1 Replies View Related

Table Headings - Aligning Text

Dec 9, 2005

Is there anyway to change the justification of text in a table heading on in the contents? I've searched high and low for an answer but can't find it.
Also, can a table heading have different text & colour than the table contents?
Thanks.

View 1 Replies View Related

Modules & VBA :: Importing Excel Data To Access Table

Mar 25, 2015

I have a VBA function to syncsuppliers as below

Function SyncSuppliers()
On Error GoTo errhandle
Filename = DLookup("SupplierPath", "Setup", "SetupActive = True")
If Filename = "" Then
Exit Function
End If
Set xlapp = CreateObject("Excel.Application")

[code]....

The 5th row is where the problem is abbot and co will import n stop missing out the brackets (I need all the data). same for the last row A-BELCO LTD will import (HADAR LIGHTING) does not.

View 2 Replies View Related

Modules & VBA :: Importing Excel Sheet Into A Table In Database

Jul 23, 2014

I am running this code to import an Excel sheet into a table in my database. This works fine if I set [HasFieldNames] to false. When [HasFieldNames] is set to true, I get the correct field names in the table, but don't get any data from the sheet.

DoCmd.TransferSpreadsheet acImport, , "txlsRevenuePayback", _
"s:ProgramsReportingPayback Revenue Table - Master Copy.xlsx", True, "Actual Revenue By Province!A12000"

View 14 Replies View Related

Modules & VBA :: Automate Importing Xml Data Into Existing Table

May 22, 2014

what is the best way to import the data from the XML file into an access database table. The database I am working with has one large main table where all of the main record data is stored. There is a somewhat complex string of queries and reports based off this table that I am concerned about preserving. The problem is that the XML file is not structured in the same way the table is. The headings are named different, aren't in the same order, etc. I cannot use the import method and simply append it to the main table.After much searching around I have found two options:

1) Use the built in XML import method that access provides to create a secondary table. Then find a way to take data from individual fields in the second table and map and insert it into a new record in the main table.I already have the import part of this option working. The only part I can't seem to understand is how to take data from the second table and get it into a new record in the main table under the correct headings

2) Read the data from the XML file all at once and then map and insert it into the main table.I have not attempted this yet. I was having a hard time understanding how to retrieve the data from the XML file in the first place.

So.. which would be better/easiest to automate (most likely via button click on a form)? I only have a small understanding of VBA and even less understanding of anything XML.

View 5 Replies View Related

Crosstab Queries, Column Headings And Lookup Table

Aug 22, 2006

Not sure if there is a quick answer but I am trying to complete a crosstab query that references a lookup table. I cannot remove the lookup tables because the database was designed by a consultant. The lookup table is referenced as the column heading. The query works fine until I change the column headings in the properties box - it returns the column headings but there are no values. Am I doing something simple wrong or is it having troubles because it is a lookup table for column headings.

View 3 Replies View Related

File Browser (importing Txt File)

Nov 14, 2006

I want to put a File Browser on a form so my users can browse their desktop for the correct TXT file they want to be imported into the database. At first, I did nto think this would be hard but it seems as though it is some what of a challenge.

Any help is appreciated.

Thank You,
Marc

View 1 Replies View Related

Queries :: Blank Returns - Datasheet With Table Headings But No Data Contents

Jun 2, 2014

I'm relatively new to access. I have a database i created for my school project everything works fine until I try running a query with 2 or more tables, the queries return a datasheet with all the table headings but no data content, I ensured that there is data in the tables that I'm trying to join for the query.

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved