PC Review


Reply
Thread Tools Rate Thread

Backups Automatically

 
 
dbalorenzini
Guest
Posts: n/a
 
      2nd Mar 2009
I have a customized ribbon on which I want to add a button that allows the
user to back up and compact the database. I know how to add buttons to the
ribbon but what commands would I use?
--
Thanks,
Art
Database Administrator
Yankton, SD
 
Reply With Quote
 
 
 
 
Jim Burke in Novi
Guest
Posts: n/a
 
      2nd Mar 2009
Here's the only way I know how to do it. First create a public function in a
module that will have VBA code that will do the backup, then create a macro
that uses the RunCode command, with the name of your backup function as the
function name for RunCode. Your button would point to the macro. You need to
include brackets when you specify the function name, e.g. if your backup
function is called CreateBackup then for Function Name in the macro you would
have CreateBackup(). I don't know of any Access commands that will create a
backup - pretty sure you have to do this with VBA. Here's a sample of what
the funciton would look like:

Public Function CreateBackup() as Boolean

Dim FSO As FileSystemObject

Set FSO = New FileSystemObject

If FSO.FileExists(DBFileName) Then
FSO.CopyFile dataFileName, backupFileName, True
CreateBackup = True
Else
CreateBackup = False
Msgbox "The file you are trying to back up does not exist."
End If

End FUnction

You need to specify the file names for your file to be backed up and the
file name you want for your backup. You'd also need to add 'standard' error
handling (an On Error GoTo... or however you handle your errors).

I think for the file system objects you need to add a reference (In VBA,
goto Tools, References). I think you need to have a reference for Windows
Script Host Object Model. Hope this helps.

Jim B

> I have a customized ribbon on which I want to add a button that allows the
> user to back up and compact the database. I know how to add buttons to the
> ribbon but what commands would I use?
> --
> Thanks,
> Art
> Database Administrator
> Yankton, SD

 
Reply With Quote
 
Jim Burke in Novi
Guest
Posts: n/a
 
      2nd Mar 2009
You also want to include this statement at the end

Set FSO = nothing

I had DBFileName in one place and dataFileName in another, but those would
both just refer to the file name of the database you're backing up. The TRUE
argument tells it to overwrite the backup file if that file name already
exists.

"Jim Burke in Novi" wrote:

> Here's the only way I know how to do it. First create a public function in a
> module that will have VBA code that will do the backup, then create a macro
> that uses the RunCode command, with the name of your backup function as the
> function name for RunCode. Your button would point to the macro. You need to
> include brackets when you specify the function name, e.g. if your backup
> function is called CreateBackup then for Function Name in the macro you would
> have CreateBackup(). I don't know of any Access commands that will create a
> backup - pretty sure you have to do this with VBA. Here's a sample of what
> the funciton would look like:
>
> Public Function CreateBackup() as Boolean
>
> Dim FSO As FileSystemObject
>
> Set FSO = New FileSystemObject
>
> If FSO.FileExists(DBFileName) Then
> FSO.CopyFile dataFileName, backupFileName, True
> CreateBackup = True
> Else
> CreateBackup = False
> Msgbox "The file you are trying to back up does not exist."
> End If
>
> End FUnction
>
> You need to specify the file names for your file to be backed up and the
> file name you want for your backup. You'd also need to add 'standard' error
> handling (an On Error GoTo... or however you handle your errors).
>
> I think for the file system objects you need to add a reference (In VBA,
> goto Tools, References). I think you need to have a reference for Windows
> Script Host Object Model. Hope this helps.
>
> Jim B
>
> > I have a customized ribbon on which I want to add a button that allows the
> > user to back up and compact the database. I know how to add buttons to the
> > ribbon but what commands would I use?
> > --
> > Thanks,
> > Art
> > Database Administrator
> > Yankton, SD

 
Reply With Quote
 
Tony Toews [MVP]
Guest
Posts: n/a
 
      8th Mar 2009
dbalorenzini <(E-Mail Removed)> wrote:

>I have a customized ribbon on which I want to add a button that allows the
>user to back up and compact the database. I know how to add buttons to the
>ribbon but what commands would I use?


When the user exits the FE attempt to rename the backend MDB
preferably with todays date in the name in yyyy-mm-dd format. Ensure
you close all bound forms, including hidden forms, and reports before
doing this. If you get an error message, oops, its busy so don't
bother. If it is successful then compact it back.

See my Backup, do you trust the users or sysadmins? tips page for more
info.
http://www.granite.ab.ca/access/backup.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007- can't get it to automatically make backups JoeZ Microsoft Excel Misc 1 17th Mar 2010 01:19 PM
xp professional - automated backup - do backups delete previous backups? Malcolm Harrison Windows XP General 3 12th Apr 2009 09:19 AM
Automatically schedule .pst backups via Backup tool? pschmidt Microsoft Outlook Discussion 2 5th Nov 2008 01:16 PM
backups shakey Windows XP Help 0 17th Sep 2004 05:52 PM
Backups Vince Windows XP General 6 30th Jun 2004 06:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:30 AM.