Automating Text File Imports

exm206

New Member
Joined
Jun 11, 2003
Messages
19
We have a database in which we created a macro on the OnClick for a button. When the end-user presses the button a text file is automatically imported into the database using import specifications we set up. Here is the code we used in the macro:

DoCmd.TransferText, acImportFixed, AutoClaim Import Specification, AutoClaim, c:\AutoClaim.txt, "0"

In this code, "AutoClaim Import Specification" is the name of the specs file, "AutoClaim" is the name of the table we are importing the data to, and "c:\AutoClaim" is the path to the text file, and the 0 siginfies that the first row of data in the text file is not column names.

This code works, it imports the text file into a table in our database. The problem is that when you run the macro the next time, it appends the data to the same table. We were hoping it would overwrite the data in the table. Does anyone know if this is possible? Thanks for the help.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
You just need to delete all the old records before iimporting the new.
something like
DoCmd.RunSQL "DELETE AutoClaim.* FROM AutoClaim;"
should do it.

HTH

Peter
 
Upvote 0

Forum statistics

Threads
1,221,556
Messages
6,160,476
Members
451,649
Latest member
fahad_ibnfurjan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top