Code linked to a form to copy and rename a file

P

Paddy

Dear forum,

I am currently building my first Access (XP) database from scratch, and

I would like to be able to enable users of this database to enter a
filename in an Access form so that, once the filename has been
specified, the (.dbf) file is copied and given a new name. Can anybody

help me with this?


(I then hope to use some borrowed code to link to the file from the
database and append the data it contains to a table in my database, but

that will have to wait until I've managed the first step, since I can't

link to the .dbf file unless the name is in the correct format - no
more than eight characters long, including spaces. )
 
G

Guest

In your VBE, set a reference to Microsoft Scriptiing Runtime. You do this in
References under the Tools menu.

In your command button's OnClick event, type this:

Dim fsoCopy As New FileSystemObject
fsoCopy Me.txtOrigFileName, Me.txtNewFileName
Set fsoCopy=Nothing

Change the text box references to the names of your controls.

HTH,
Barry
 
D

Douglas J Steele

Why on earth introduce the overhead of FSO when the VBA FileCopy command
will suffice?

FileCopy Me.txtOrigFileName, Me.txtNewFileName
 
G

Guest

Why on earth? Because FileSystemObjects are cool. They make me all giddy and
tingly, just like a little girl. I like to lay awake at night thinking of how
dreamy FSO's are, with all their methods and properties.
 

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

Similar Threads


Top