Question : Import and evaluation

I have a fixed-length text file that I will need to import from time to time into a master access table. I have defined the file's fields using the import wizard and have saved this as a definition. What I need to do is on import I need evaluate each record at a time and place the corresponding fields into the master table. I need to automate this with VBA using my stored definition file.

I'm looking for a VBA example of the process I described as I need to automate this and attach it to a  command button.

Answer : Import and evaluation

If your evaluation consists only of changing codes, you do not even need to use  VBA and can achieve it using macros and queries.
1 Create a table  ('row_table') with exactly the same data structure as your text file. Import data from text file into this table using import wizard. At the end of the import process save the specification. You will need it when you create import macros.
Create tables with correspondance of codes you need to change:
For you exapmle the table would be:
codes_table:
code_from code_to
1         ENR
0         EXT
Create  make table query that joins the row_table with codes_table on the code putting into select list column from codes_table. run this query once to create your final_table and change it to append query.
modify your final_table if needed (change data_types and add indexes)
Create macro, that do the following
1. Deletes all rows from row_table (RunSql  action "delete * from row_table")
2. imports data from your text file (TransferDatabase action , here you will need your daved spec.)
3. Deletes all rows from final_table
4. Runs append query to populate final_table (OpenQuery action)
If you do not to be prompted about deletion and insertions add
SetWarnings No action at the begining of the macro and SetWarnings Yes at the end of the macro.

Random Solutions  
 
programming4us programming4us