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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

backing up a database using a command button.

Status
Not open for further replies.

Junior1544

Technical User
Apr 20, 2001
1,267
US
I don't exacly know how to do this...

what i want to do is create a command button on a form that will copy all of the files in my database directory to another directory that is based on the date, ex:
c:\database\backup\05122002
for today's date... i have a couple of idea's, but i'm not sure what to do... and i have no idea how to do this... in doing this i also want to supress any warnings, for example, asking to overwrite any files already there... if there's a file i want it over writen by default...

tia...
--Junior JHauge@jmjpc.net
Life is change. To deny change is to deny life.
 
this is not the first time i've asked this here, but i just found the answer(well, close enough) in this thred

thread181-270508 will post just the code as i've changed it to fit my needs in another reply in this thred...

mine is uncommented... but fairly simple and strait forward...

thanks...

--Junior
JHauge@jmjpc.net
Life is change. To deny change is to deny life.
 
Private Sub Form_Close()

Dim strRootPath
Dim strFileName

Dim objScript

Dim strdate
Dim strMonth
Dim strDay
Dim strYear

Dim strSource
Dim strTarget
Dim strMsg


strRootPath = "c:\security\"
'strRootPath = "\\rdechq01209\security\"

strMonth = DatePart("m", Date)
If Len(strMonth) = 1 Then strMonth = "0" & strMonth

strDay = DatePart("d", Date)
If Len(strDay) = 1 Then strDay = "0" & strDay

strYear = Right(DatePart("yyyy", Date), 2)


strdate = strMonth & strDay & strYear

strSource = strRootPath & "*.*"
strTarget = strRootPath & "backup\" & strdate & "\"

Set objScript = CreateObject("Scripting.FileSystemObject")

If Not objScript.FolderExists(strRootPath & "backup\") Then
objScript.CreateFolder (strRootPath & "backup\")
End If

If Not objScript.FolderExists(strRootPath & "backup\" & strdate & "\") Then
objScript.CreateFolder (strRootPath & "backup\" & strdate & "\")
End If

objScript.CopyFile strSource, strTarget

Set objScript = Nothing

End Sub
JHauge@jmjpc.net
Life is change. To deny change is to deny life.
 
i'm sure there is an easier or more strait forward way of doing this, but it's the best i could get in the code:)

--Junior JHauge@jmjpc.net
Life is change. To deny change is to deny life.
 
Hi.
In the FAQ's, JimmyTheGeek has posted the code for what you want. Work's splendidly! Just search "back up" in FAQ's on this forum.
Cheers. Gus Brunston :cool: An old PICKer, using Access2000. I manage Suggestions welcome. padregus@attbi.com
 
thank you, i had searched every where a while ago, i guess i just didn't find it...

--Junior JHauge@jmjpc.net
Life is change. To deny change is to deny life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top