msdos file operations (1 Viewer)

ayjayh

Registered User.
Local time
Today, 21:13
Joined
Mar 29, 2002
Messages
20
I need to be able to import a table (dbase3) from a floppy disc to update a table in Access. To do this I would like to do the following file operations using a macro.
1) check for presence of the file on the floppy (a:\Tillsale.dbf).
2) Import the floppy to Access then update the Access table (I know how to do this bit)
3) Rename the original floppy file as a:\tillsale.saf
Hope you can help,
Tony
 

fmm

Registered User.
Local time
Today, 15:13
Joined
Mar 15, 2001
Messages
76
In VBA:

if len(dir("a:\tillsale.dbf")) > 0 then
'File exists
'Put your import code here
'Now rename the original
FileCopy "a:\tillsale.dbf", "a:\tillsale.saf"
Kill "a:\tillsale.dbf"
else
'File does not exist
end if


If there's not enough room on the floppy to make a copy and then kill the original, use FileCopy to put a temp copy on your hard drive, Kill the original on a:, FileCopy from the hard drive to the floppy, and Kill the hard drive copy.
 

ayjayh

Registered User.
Local time
Today, 21:13
Joined
Mar 29, 2002
Messages
20
Thanks for that very quick reply.
Unfortunately you are dealing with a thicko here. When I said I could do the Import bit OK I was thinking of using a macro. The idea of putting inside a bit of VBA code appeals to me so could you elaborate on that for me please.
Also, being a thicko, I don't know how to use the bit of VBA code. How do I get that into the game? Does it go into a macro or a Module or something else?
Thanks in advance for your patience.
Tony
 

fmm

Registered User.
Local time
Today, 15:13
Joined
Mar 15, 2001
Messages
76
I'd do it on a form with a button:

On a form, create a button. I usually choose the Form Operations category and the Close form action (there's probably a better way but I'm too lazy to find it).

Name the button (say cmdImportFile) and view the code behind the form.

Look for the line Private Sub cmdImportFile_Click(), which will have basically one line of code: DoCmd.Close. Replace this with the code I gave you before (you will have to work out the actual import on your own) and that should be it.

[This message has been edited by fmm (edited 05-08-2002).]
 

ayjayh

Registered User.
Local time
Today, 21:13
Joined
Mar 29, 2002
Messages
20
Thanks FMM, it works a treat. Once again I am amazed at the response everyone gets from this BB.
Tony
 

Users who are viewing this thread

Top Bottom