Hi Jason,
I think I have a better feel for what you are trying to
do now. I'm not sure if you have been able to get the
Application.Filesearch to work yet, but I think that will
be very important to do what you want to do (if anyone
knows of another way to generate a list of files in a
folder please let us know). I'm not sure if you saw my
other post, but check in the VB code window under
Tools|References to see if Microsoft Office Library is
checked - I think it needs to be to use
Application.Filesearch.
Anyway, if you can get this working, you could do what
you want to do as follows.
Run Application.Filesearch to generate the collection of
files meeting your criteria.
Loop through each of the files to do the following:
1. Import to a temporary table
2. Run an append query to append the record(s) to your
main table.
3. Go to the next file in the loop.
The Application.Filesearch should be the only part that
is somewhat tricky if all of your excel files that you
will be importing are in the same format (which it sounds
like they are). And, from looking at the earlier code
that you had posted, it looks like you have written most
of the code for it, if you can only figure out what is
causing your error.
I'm not sure how well you know the debugging tools in VB,
but they often help me figure out what is wrong. You
could set a breakpoint just before your error line, and
look at all of the values of the variables at that point
in the locals window, that may help locate the problem.
Maybe others will have some other ideas, but I thought I
would pass this along.
-Ted
-----Original Message-----
Hello John...
I could not agree with you more on the linking issue.
Currently, (and since I cannot get the problem solved
yet) I am only linking to one .xl file and basing queries
off of that. I *really* want to be able to import data
from several .xls files into one table... as opposed to
merely linking them. There will end up being wayyyy too
many linked tables if I don't!
Basically this is what happens now:
..xls files are exported from a 3rd party app. These
files are exported at any given time during the day, each
one has a unique filename (123-1234.xls, 133-1234.xls,
542-1243.xls, etc) and are exported to the directory of
my choosing.
The data basically includes a jobID, partID,
Description, and more.. these values never change, as the
data goes from the 3rd party app to the .xls file via
Crystal Reports. That data is then queried and a "master
list" is generated via a report.
I am using an input device (barcode scanner) that allows
us to scan items and bounce those scanned items off of
the "master list" to produce 2 more reports: a "scanned"
report (items on the master that *have* been scanned) and
an "unscanned" report (items on the master that have yet
to be scanned). The unique field in these operations are
the JobID and ItemID fields.
I have this running fabulously fine as we speak. No
problems whatsoever, with the exception of the applicatin
being limited with only ONE .xls file. The way things are
now, I have to have people export the .xls file to a
unique filename so that the Access mdb can link the info.
We need to be able to export an infinate amount of .xls
files to work with, as we need to be able to work on more
than one JobID at a time, as opposed to the current (1).
I want to be able to scan the said directory of all xls
files and maybe append all of their data into one table.
The query operations should not be a factor, as the jobID
will forever be unique, and the reports could be
generated simply based on that value alone.
I understand that I cannot simply "link" hundreds of xls
files to the mdb programmatically, but I have absolutely
NO idea on how to get the data from multiple files into
one table without manually importing the data. Doing so
is just NOT an option, as we have to allow for any given
workstation to export a new dataset at any given moment.
Only one person is using this access tool.
~I hope this explains everything adequately. I am so
seriously stumped and pressed for time here, I think I am
going to start bleeding out my ears. hehe. In any case I
do appreciate any and ALL help on this matter. Thanks
again!