Import previously imported file

G

Guest

Hi. Maybe I'm just plain ignorant (not all that unlikely...), but I'm stuck.
I'm using the code for Ken Getz's "GetOpenFile" function to open a file from
a specific location and use that file for an import. I need to import the
same file again under a seperate import specification for another part of the
same process in the same database... if anyone is familiar with this code,
could you help me figure out how to call the same file twice so I can import
it under the other import spec?
 
G

Guest

once you've returned the file name:

After you've done the import the 1st time:

File_to_import = GetOpenFile

DoCmd.TransferText acImportDelim, Specification_name1, tbltable_name1,
File_to_import1, False, ""


Can't you simply insert it into a new import statement?

DoCmd.TransferText acImportDelim, Specification_name2, tbltable_name2,
File_to_import, False, ""

or is it more complicated than that?

I haven't actally tried this, just seems like it should work..??
 
G

Guest

I tried that, it didn't work right... the problem is I am using an Open File
dialog box to open the file. If the filename was constant I wouldn't have
this problem but unfortunately for me the files that I need will never have
the same name. I have the DB working right now, but in order to do it I have
to open the same file twwice through the same code, and format the imported
data appropriately. So basically I need to be able to either A) import the
data to two tables simultaneously using two completely different input
formats and column sizes (which will NEVER work... at least not without a TON
of formatting queries), or figure out which variable in the code I'm using
stores the name of the file and call that same name again in the
DoCmd.TransferText function. At the moment, I'm not having much luck with
either.
 
R

RD

You say that you're importing the same file twice but it never has the same
name? Does it change names after the first import? If not then BAC's
suggestion should work. Why don't you post your TransferText code and somebody
will tell you which variable holds the file name.

Regards,
RD
 
R

RD

Ok, that's your OpenFile dialog but not your TransferText code. The GetOpenFile
function returns the file name. Then you pass that name into yout TransferText.
So, why don't you post yout TransferText code so we can take a look at it?
 
G

Guest

My TransferText is in a macro, and I run =GetOpenFile("file\dir","Open
Such'n'such File") in the filename box. My problem isn't the TransferText, I
can handle that easily. I just need to know what variable from GetOpenFile
stores the filename so I can call that to open the file the second time with
a different function (I guess it'd be a function?). I think the command in VB
form would be:

DoCmd.TransferText acImportFixed, File Import Spec, "Customer Table",
GetOpenFile("start directory","Dialog Box Name"), etc. etc. etc. So is
GetOpenFile the variable? And if so, how do I call that to open the file
twice?
 
R

RD

I see. I didn't realize you were using a Macro.

Ok, GetOpenFile gets the name(path) of the file. In code you would assign that
value to a variable:
sMyFile = GetOpenFile(etc.)

Then you would use that variable in two different TransferText methods as in
BAC's example. I think using a macro you *would* have to open the File Dialog
twice. In code you open once, assign to a variable and use the variable twice.

Much more gooder than macros.

I've been dinking around with Access for ten years and in all that time I think
I've written maybe three macros (other than AutoExecs). Don't like 'em.

Are we getting any closer to solving your problem?
 

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