I have an application that creates a backup file of data in an Oracle db as a comma delimited text file. I’m basically trying to reverse the process and take the comma delimited file and turn it into multiple tables in Access with the same field names and data contained in the Oracle DB.
I’ve written an Access application that imports the data from the backup file and allows me to view or print reports of the contents of the backup file.
I’m using the transfertext action in a macro to import the comma delimited text file. I end up with one table with Field1 through Field217. From this table I have queries that separate the data into multiple tables. The queries work fine for all but one of the tables. One of the tables has a field where the original data contains one or more commas, the backup file contains the commas, but also has commas separating the fields. When I import the text file it breaks up the text into fields between the commas. Some of the single fields end up being split into multiple fields if there are actual commas in them instead of just commas separating the fields. Not only does this cause multiple fields to have to be combined, it also shifts any following data into the next field(s).
I’ve written a query that works, but only up to 3 actual commas in a field. I can’t account for anymore or I get a “Too Complex to be Evaluated” error.
I was thinking of a way to use a couple of variables to determine the fields to combine and the starting field based on commas in the previous fields.
There’s probably a better way to import this file through some code that will just import the data between the 1st 2 commas into Field1, between the 2nd 2 commas into Field2, etc…
Here’s some sample data
Oracle DB
Field1 Field2 Field3 Field4
1. abcd 1234 795 dfge
2. ace,gf 2213 292 dbcb
3. gnr,qrc,b 3351 925 vxgp
Backup Text File
1. "abcd","1234","795","dfge"
2. "ace,gf","2213","292","dbcb"
3 "gnr,qrc,b","3351","925","vxgp"
Access (Imported Backup Text File)
Field1 Field2 Field3 Field4 Field5 Field6
1. "abcd" "1234" "795" "dfge" null null
2. "ace gf" "2213" "292" "dbcb" null
3. "gnr qrc b" "3351" "925" "vxgp"