Import using Variable

rschultz

Registered User.
Local time
Today, 09:36
Joined
Apr 25, 2001
Messages
96
I can import a text file using the following code:

Docmd.TransferText , , "Crinc Temp", "C:\Access\Rec_1019.txt", False

but I want to be able to place a textbox on a form and have the user be able to enter the textfile name they want to import (the text file is always the date so it will change) - make that filename a variable and place that variable in the code listed above. How do I go about that? I keep getting a 'Micorsoft Jet could not find the object imp_file". Imp_file is the variable I'm trying to use as the Date entered in the textbox.
 
Solved it! HEre is the solution of anyone needs it:

Dim imp_file As String
imp_file = Me!Text0
Docmd.TransferText , , "Crinc Temp", "C:\Access\" & imp_file, False
 
This was exactly what I was looking for!! But I have a question for you to see if you may know how to solve it.

Access 97 - TransferText import. I have the user prompted to find the files to import - works fine, but the user has to go through a step to import a total of 6 files. I'd rather have the user input a number that is included on all 6 of these files and would be at the beginnging. Could be 4 to 6 characters long. All 6 files have a unique last 3 digit code that defines what table they are to be imported. In between these two sets of characters is a date time stamp.

Is it possible to code so the user only has to import the beginning number? Oh - the files are always located in the same spot...

The format of the file is

XXXXXX_CCYYMMDD_HHMMSS_YYY

X is the Plan number and can be 4-6 digits and Y is the unique three digit code. YYY can be - AGD, AGN, BIL, COM, DAT, or PLN.

Thanks in advance if you can help!!
Carie
 
Just let the user select any one of the files, strip the three-character code off the selected name, and set up a loop to do the import six times. On each iteration of the loop, append a different three-character code to the stub of the file name and use the resulting name as the source file for the import.
 

Users who are viewing this thread

Back
Top Bottom