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 db file thru code if specified db does not exist in folder

Status
Not open for further replies.
Jan 14, 2002
143
US
Hi, can someome tell me if I can use a procedure to look for a specific .mdb file in a folder, and if the file does not exist, copy an existing .mdb in the same folder and name it the specified file I was looking for?

Say I'm looking for f:\Access\PMP\A2002.mdb
It's nonexistant so I copy f:\Access\PMP\HolyBlankDb.mdb and name the new copy A2002.mdb


Thanks in advance







 
I think this is what you're looking for, put the following in a button's cclick event:

Dim fs, f, s, filespec
Dim strFileName As String
strFileName = "f:\Access\PMP\A2002.mdb" 'maybe break this upo into strFileName and strFileFolder
filespec = strFileName
Set fs = CreateObject("Scripting.FileSystemObject")
f = fs.FileExists(filespec)
MsgBox f ' just to test that it returns true if c:\my documents\NWind.mdb exists, else false
'If f = False Then ' unrem to use, use variables if you want
' FileCopy "f:\Access\PMP\HolyBlankDb.mdb", "f:\Access\PMP\A2002.mdb"
'End If

Let me know if you have any problems.

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top