Importing Data

G

Guest

My question is rather complex. I receive a text file everyday. Unfortunately,
within the text filename is the date of the data. For example, abc060224.txt
and tomorrow will be abc060225.txt
The files are imported each day by clicking a command button which kicks off
a macro.

My question is there anyway of access changing the name of the file it is
importing each day? Or requesting information pertaining to the filename it
is importing via a pop up window?

Any help would be greatly appreciated.
 
D

Douglas J Steele

Yes to both possibilities you mention.

Assuming you're using TransferText, you can use a variable for the file
name.

You can set that variable either through code ("strFile = "abc" &
Format(Date(), "yymmdd") & ".txt"), or you can use the standard Windows File
Open dialog to allow the user to select the file (see
http://www.mvps.org/access/api/api0001.htm at "The Access Web" for the best
way to do that)
 
P

Phillip Windell

1. Assuming all these files are in a folder all by themselves... loop
through
the files in the folder with the FileSystem Object. If they aren't in a
folder
by themselves, it would really really really help if you could make it
that way.
2. Use the Filesystem Object to get each file's date, which should
be the same as the date in the name.
3. Compare it to Now() [which would be today's date]
4. When you find the match, the FileSystem Object will already have the
name,..use it.

I'm not much of a "programmer",..I can't give you exact code. I can only
communicate the "idea".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top