Backup In VBA

snc

New member
Local time
Today, 18:01
Joined
Mar 29, 2007
Messages
2
Hello I am currently doing a i.t course and i am currently doing my massive project
i am creating a dasebase for a hair salon
what i want is to when it closes to create a back up but all i am getting is copydatabasefile is'nt avilble now ??

here is my code simple

Option Compare Database

Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Dim intResponse As Integer
Dim strFileName As String
intResponse = MsgBox("Are you sure you want to Quit?", vbYesNo, "Warning!!")
If intResponse = 6 Then
DoCmd.CopyDatabaseFile DatabaseFileName:="P:\Backup\Zion Appointment System Backup " & Now & ".mdb", OverwriteExistingFile:=False, DisconnectAllUsers:=True
End
Else
DoCmd.Close

End If


Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description


Resume Exit_Command0_Click


End Sub



I hope you can help out



Many Thanks
Robert
 
Softboss..

Thank you very much, you are right it is my lucky day... Just what I was looking for!!!

R~
 
Very Nice Mr. OldSoftBoss
1. It is possible to backup just the table, not the whole DB?
2. It is possible to Backup the Table Data of MDE to a MDB?
 
HELP!!!
I want to use the above Utility for backup, but I dont like to buckup the whole Db, I want to buckup just the tables and using the above utility, How it is possible?
 
Last edited:
Hello EveryOne,
Want to use the above utility just backup the tables not the whole DB.
How can I do that plz help...
 
I don't think you can just back up 1 table - not in this manner

you could do an append qry and run this off a macro
back this data off either into another table or onto a separate d/base

but it does weird that you want just 1 table backed up

its like parking your car in the garage but you only want to garage 1 wheel of the car .. you can do it , but you would have to take the wheel off .. a lots of work considering when you can park the whole car
 
Use the backup utility to back up the backend - which only has tables !!
 
Fantastic utility thanks - query it is working as a standalone database and copies everything correctly - can I add it into a database to be called up with a button - have tried to import the modules etc but am now getting a compile error.

Maybe doing something silly.

Thanks

Humph
 
If you already have a backup database, just use docmd.transfterdatabase command transfer the table the backup database.

Or you create that database first then transfer the table.

Here is the syntax:

DoCmd.TransferDatabase(TransferType, DatabaseType, DatabaseName, ObjectType, Source, Destination, StructureOnly, StoreLogin)
 
What compile error? Check for missing reference - differences between the stand alone db and your Db.

Also check for copied functions (IsLoaded etc) If you have then in twice the Db will spit it.

Dave
 
Back up now working

:DThanks for all your help - got it to work by importing my database into the back up utility rather than the other way around - don't understand why it works this way but the important thing is that it does.

Once again a fantastic utility many thanks
 
Hi all,

Been very interested reading these posts. I have previously asked something similar. However I would like to know whether there is a routine that backs up several or a number of files to a chosen directory. By the way I'm using A97 but considering similar routine for A2000.

Thank to all
 
Use DoCmd.OutputTo command. But I am not sure this command is available in A97
 
What compile error? Check for missing reference - differences between the stand alone db and your Db.

Also check for copied functions (IsLoaded etc) If you have then in twice the Db will spit it.

Dave

Hi Oldsoftboss,

As my screen name states I am a rookie at this, I love your backup utility, just what I am looking for a front end DB. I export it to my DB and I am getting the following comple error?

"User-Defined type not defined" and it highlights "Dim fso As FileSystemObject"

I really would benefit from your backup utility any suggestions?
 
You need to check your references and compare them to the sample db
 
I don't want to use the utility although it's great. (but not suitable for my case)

I want to use the CopyDatabaseFile command. but all i am getting is copydatabasefile isn't available now ?? error#2046
 
Here is a batch file that is run from a macro. There are actually two of them as one is for when the macro is run between midnight and 10am and between 10am and midnight.

The db is called Viper.mdb and is in My Documents. The DB is copied to two external hard drives and two other computers on the network and also the computer it is run from. There is a variation of the batch file to allow the backup to be run from either of the two computers on the network.

1) The DB is copied to a folder called ViperTransfer. It is then renamed to include time and date. It gets a name like Viper103913-29052008.mdb. This is done so each copy does not over ride the previous copy. Similar in to what Oldsoftboss backup does. Continually overriding a copy will mean if there is a problem then your only copy will have the problem. A date/time in the copy also tells you when it was done.

2) From ViperTransfer it is copied to a folder called ViperDaily on each hard disk.

3) The first part of the batch file copies it from ViperDaily folder to a folder called Viper Archive and then deletes it from ViperDaily. The first time it is run the folder ViperDaily would be empty but that is no problem as the batch file just runs through that part.

4) J; and k: are the external hard drives and 378mike and 378wby are two computers on the network.

c:

copy \ViperDaily\*.mdb \ViperArchive
Del \ViperDaily /Q

cd\
copy \\378Wby\ViperDaily\*.mdb \\378Wby\ViperArchive
Del \\378Wby\ViperDaily /Q

copy \\378mike\ViperDaily\*.mdb \\378mike\ViperArchive
Del \\378mike\ViperDaily /Q

copy j:\ViperDailyj j:\ViperArchivej
Del j:\ViperDailyj /Q

copy k:\ViperDailyk k:\ViperArchivek
Del k:\ViperDailyk /Q

cd\ViperTransfer

ren *.mdb Viper.mdb

cd\Documents and Settings\John\My Documents

copy viper.mdb \ViperTransfer

cd\ViperTransfer

set Day=%Date:~4,2%
set Mth=%Date:~7,2%
set Yr=%Date:~10,4%
set Hr=%Time:~0,2%
set Min=%Time:~3,2%
set Sec=%Time:~6,2%

ren *.mdb Viper%Hr%%Min%%Sec%-%Day%%Mth%%Yr%.mdb

copy *.mdb \\378Wby\ViperDaily
copy *.mdb c:\ViperDaily
copy *.mdb j:\ViperDailyj
copy *.mdb k:\ViperDailyk
copy *.mdb \\378mike\ViperDaily
 
Last edited:
Simple Software Solutions

Not wishing to undemine any previous threads or submissions, please find an attachment that performs the following:

1st Asks the user if they want to back up when the project closes
2nd checkes for previous backups for the same day (option to overwrite)
3rd compacts the specified mdb
4th creates a zip file of the specified mdb
5th saves it to the specified location

Caution:
You need to read the attached documentation first prior to running it.
Remember to include the DAO 3.6 objects library in your references.


Any comments or suggestions are welcome.

CodeMaster::cool:
http://www.icraftlimited.co.uk
 

Attachments

Predator Software Backup Utility:

OSB-

I like the way this looks and is setup.

My question would be how can I get it to work by backing up a specific location where the drive letter is unknown?

Example:

I am creating an installation program for the database which will get installed in the: \Program Files\Financial Solutions\ folder. But some PC's are setup differently and the the "Program Files" folder could be on C:\; D:\; F:\; etc.

What I want to do is have the "Path to file" be static to the installation folder.

Same with the "Destination Directory" I want this to be \Program Files\Financial Solutions\Backup\

Does anyone have any ideas on how I can accomplish this?
 

Users who are viewing this thread

Back
Top Bottom