Backingup to another location on system

satty

Board Regular
Joined
Jan 12, 2003
Messages
68
Hey guys,

i have a very tricky question this time. hopefully not... :wink:

1 - In MS Excel it is possible to create a backup upon saving the file. Is this possible to do in MS Access 2000?

<-If Yes->

2 - In MS Excel, the backup used to get saved at the same location as the original file. Is it possible to make this backup save in another folder when the MS Access database is closed?

In addition to this, i would prefer if the backedup database could be saved with a filename of the date.

I totally dont have a clue if this is possible, if yes please give it a shot!!


Thanx people!! get crackin :p


Satty
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
The quick and dirty approach is to use the built-in Macros to back up copies of your tables to another database. Caveat: the database must be pre-existing (therefore, the latest backup overwrites the earlier ones).
The more complex but flexible route is to write your own code, using the TransferDatabase method to copy items to another location.
Check out http://www.helenfeddema.com and Dev Ashsish's site (The Access Web), on http://www.mvps.org for code ideas.

Denis
 
Upvote 0
If anyone can remember to write DOS batch files then you could create a batch file to do the copying and pasting for you and run the batch file using the Shell Command.

Now all we need is someone who can remember how to use variable naming in DOS :)

Peter
 
Upvote 0
These two subs run for me within Access2K. Other DOS commands are possible.
Code:
Sub sCopyFile(ByVal strSource As String, ByVal strCopy As String)

strCopy = " /c copy " & strSource & " " & strCopy

Call Shell(Environ$("COMSPEC") & strCopy, vbNormalFocus)
DoEvents

End Sub

Sub sDeleteTarget(ByVal MyTarg As String)

MyTarg = " /c del " & MyTarg
' MyTarg = " /c del S:\directory\file.ext"  as the format of MyTarg
Call Shell(Environ$("COMSPEC") & MyTarg, vbNormalFocus)
DoEvents

End Sub
 
Upvote 0
Only thing to add to this is I remember having the classic 'DoEvents doesn't really pause program execution to allow the Shell Command to finish problem'...so, I use a little routine that inserts a 2 second pause

Code:
Private Declare Sub sapiSleep Lib "kernel32" _
        Alias "Sleep" _
        (ByVal dwMilliseconds As Long)
'---insert above at top of module

'---below is the actual sub
Sub sSleep(lngMilliSec As Long)
    If lngMilliSec > 0 Then
        Call sapiSleep(lngMilliSec)
    End If
End Sub

And for Satty's benefit although I did answer in PM.

Call both the copy and timer functions like this within a function.
Use any variable names you wish, of course, variables named for example clarity.

Code:
  Call sCopyFile(strSourceFile, strDestFile) 
  Call sSleep(intValue)

Mike
 
Upvote 0
i bet u guys r thinkin wat a thicko!! sorry guys i just aint gettin this. this is what i have got so far as the final codes.

am i suppose to enter this in a module?

Option Compare Database

Private Declare Sub sapiSleep Lib "kernel32" _
Alias "Sleep" _
(ByVal dwMilliseconds As Long)
'---insert above at top of module

Sub sCopyFile(ByVal strSource As String, ByVal strCopy As String)

strCopy = " C:\Documents and Settings\Administrator\Desktop" & strSource & "Backup" & strCopy

Call Shell(Environ$("COMSPEC") & strCopy, vbNormalFocus)
DoEvents

End Sub

Sub sDeleteTarget(ByVal MyTarg As String)

MyTarg = " C:\Documents and Settings\Administrator\My Documents\Satty\A2 ICT Project" & MyTarg
' MyTarg = " /c del S:\directory\file.ext" as the format of MyTarg
Call Shell(Environ$("COMSPEC") & MyTarg, vbNormalFocus)
DoEvents

End Sub

'---below is the actual sub
Sub sSleep(lngMilliSec As Long)
If lngMilliSec > 0 Then
Call sapiSleep(lngMilliSec)
End If
End Sub

i think i have done this totally wrong! nothing happens?

sorry guys...


Satty
 
Upvote 0
Just came across a tutorial -- on Helen Feddema's website. Access Archon #115 covers code for saving an Access database as another db, from within Access, using a form interface. You get to choose the filename.
http://www.helenfeddema.com/access.htm it's near the bottom of the page.

Denis
 
Upvote 0
Satty,

I'm sorry, I think I've just confused you.
My code snippets do not handle the entire question you presented. Really, I was responding to bat17's DOS batch file comment with a subroutine that did the same thing without needing to execute a *.bat file.

The subroutines I posted do one small task. If you had the ability to write a VBA Function already - you could write one that called those subroutines and they could issue DOS commands that would copy/delete files. DOS, btw, is not part of Access/Excel or VBA. It's part of the original Microsoft operating system - support (or virtual support) for which is included on all versions of Windows (currently).

At this point, I think it might be easier or more informative for you to follow SydneyGeek's links which he very kindly posted twice. Feel free to copy the routines somewhere handy with some notes as to how to use them, should you in the future need to use them for something.

My actual personal use was to automate the rebuilding of an xls 'client'. In the near inevitable event that the users would *do something bad* to a spreadsheet I gave them for data-entry, I wanted to be able to copy a blank template xls to the new location and then I used transferspreadsheet to push the data out of an access database. Obviously, this is a different kind of problem from what you have - it could be made to work for you, but, frankly, I would not have attempted this method for your particular question.

Good luck

Mike
 
Upvote 0

Forum statistics

Threads
1,215,736
Messages
6,126,552
Members
449,318
Latest member
Son Raphon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top