|
|
Question : create cmd button to copy db and then rename it.
|
|
Hi there, how do I create a command button to? When I click on this button I want to do the following:
1. Create a copy of Test.mdb 2. Rename the copy of Test.mdb and add current date. For example, Test_02022005.mdb
Thanks
|
Answer : create cmd button to copy db and then rename it.
|
|
Hmm, best to use this:
dim strSource as string dim strTarget as string
strSource = "C:/Test/Test.mdb" strTarget = "C:/TestSave/Test" & Format(Date, "yyyymmdd") & ".mdb"
If Dir(strSource) = "" Then msgbox "Source " & strSource & " not found, aborting copy." exit sub endif If Dir(strTarget) = "" Then ' Do you change FileCopy strSource, strTarget Else If MsgBox("File " & strTarget & " exists, overwrite?", vbYesNo) = vbYes Then Kill strTarget FileCopy strSource, strTarget End If End If
Looks to me we can do the FileCopy and name change in one go.
Nic;o)
|
|
|
|
|