backup access 2003

  • Thread starter Thread starter Eef
  • Start date Start date
E

Eef

I want to start the Backup option from >File >Backup via VBA

I tried
DoCmd.RunCommand acCmdBackup

I get a message like "Not available"
Original in Dutch:
Fout 2046 tijdens de uitvoering:
De opdracht of actie Back-up is momenteel niet beschikbaar

What could be the correct procedure?

Eef
 
Try this workaround:
CommandBars("Menu Bar"). _
Controls("Tools"). _
Controls("Database utilities"). _
Controls("Back Up Database..."). _
accDoDefaultAction

Barry
 
Berry,

Thank you for answering.
No succes, however.

I get:
Error nr. 5
Ongeldige procedure-aanroep of ongeldig argument

with this procedure:

Dim cbars As CommandBars
Dim controls As CommandBarControl

CommandBars("Menu Bar"). _
controls("Tools"). _
controls("Database utilities"). _
controls("Back Up Database..."). _
accDoDefaultAction

Any suggestions?
Eef
 
Please confirm the version of Access you are using. I think that, to use this
function, you need to use Access 2002/2003 with the 2002.2003 format, not the
Acc2000 format.

Barry
 
Your main menubar must also be visible. If you cannot see the Tools, Database
Utilities, Backup Database... from the menu, then it will not run with this
code.

Barry
 
Can you outline why you want to use File, Backup in code?

One usually splits a database into frontend/backend. Using such code would
backup the frontend only, which likely isn't necessary in a production
environment.

There are likely better ways of accomplishing what you want, if you'd like
to explain.
 
Barry,

The menubar and options are visible. On a later date I will look into this.
For the time being I use the following procedure (main part shown):

Dim fileObj As Object
Dim strBestandNaam As String
Dim strBackupNaam As String
Dim msg As Integer

Let strBestandNaam = "EHBO_Leden.mdb"
Let strBackupNaam = Format$(Now(), "yyyymmdd") & "_BU_" & strBestandNaam

Let strBestandNaam = "C:\EHBO_Leden\" & strBestandNaam
Let strBackupNaam = "C:\EHBO_Leden\Reserve\" & strBackupNaam
Set fileObj = CreateObject("scripting.filesystemobject")
fileObj.CopyFile strBestandNaam, strBackupNaam, True

msg = MsgBox("Een Back-Up van de bestaande database is opgeslagen als:"
& vbCrLf & vbCrLf & _
strBackupNaam, vbInformation, conNaamToep)

Thank you for your trouble.
Eef
 
Joan,

The DB is rather small, not split, and to be used by a novice-user.

Since I found the option acCmdBackup , I hoped the procedure
docmd.RunCommand acCmdBackup
could be used.
That however seems not to be the case.

In my answer to Barry I showed the method I will use to further notice.

Thank you for reacting to my question.
Eef
 
As Joan pointed out, your database should be split. It doesn't matter
whether it's small or your user is a novice.

Having it split makes it much simpler for you to make changes to the
functionality of the database. It also gives you the ability not only to
backup the back-end database from the front-end, but to compact the back-end
when you do.
 
Back
Top