Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy a access database file and rename

Status
Not open for further replies.

Judalie

Programmer
Mar 25, 2002
40
US
I am very knew at VB..but work with access... I have created an access db program that will be helpful to other people within my organization, however there is one step that needs to be made simpler for the users...that is... i have a 'blank.mdb' file that needs to be copied and renamed. Can I do with with VB..can someone help me get started in the right direction?

thanks so much for any help you can give..

j
 
it is safe to say, knew is not the word...new...sorry/j
 
The simplest way is to use the FileCopy command.

FileCopy Source As String, Destination As String

So you'd do something like

FileCopy "C:\MyProject\blank.mdb", "C:\MyProject\active.mdb"
 
Shroeder:
thanks so much.. It works...
i'm going to create a field to name the new file so they can choose different names..but i think i know how to do that..so i'm on my way and thanks so much!
j
 
Hi Schroeder
If I use an input box...
Private Sub Command1_Click()
Text1 = InputBox("Enter new file name, remember to end with .mdb")
FileCopy "blank.mdb", Text1
End Sub

" I would rather ask them for the city location
"Enter the city location"

(which will be the file name)...and then add the ".mdb" myself... how can i write this..

FileCopy "blank.mdb", Text1.mdb....to be sure the Text1 picks up the data not
"Text1"...

thanks,j

 
You can concatenate strings together using "&".
After this:

Dim strFileName As String
strFileName = "NewYork" & ".mdb"

strFileName will contain "NewYork.mdb". So you'd say:

FileCopy "blank.mdb", Text1 & ".mdb"
 
last question...

want to add the file
as a shortcut on the desktop..
is there an easy way to do this in vb?

i'm going to take some classes...later, i promise,j
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top