Copy, Zip, And send database button

PatrickJohnson

Registered User.
Local time
Today, 14:04
Joined
Jan 26, 2007
Messages
68
Anyone have an idea how I can have access copy the entire database, zip it up, and send it via email with a button click?
 
I believe I'm correct in saying that up thru Access 2003 you cannot copy a database from within the database. I'm not sure about the latest version.
 
Below is an example, the file path and name for the Access db and WinZip file can contain NO spaces.

Code:
Sub SaveAndSend()
    
    Dim sCopiedFile As String
    Dim sWinZipFile As String
    Dim OutlookApp As Object
    Dim OlMailItm As Object
    
    sCopiedFile = "H:\FileCopy.mdb"
    sWinZipFile = "H:\EmailCopy.zip"
    
     
    
    DoCmd.RunCommand acCmdSaveAs, sCopiedFile
    Shell "C:\Program Files\WinZip\WINZIP32.EXE -a " & sWinZipFile & " " & sCopiedFile
    Kill sCopiedFile
    
    Set OutlookApp = CreateObject("Outlook.Application")
    'Create a new MailItem
    Set OlMailItm = OutlookApp.CreateItem(0)
        
                        
    OlMailItm.Recipients.Add ("JoeBlow@yahoo.com")
    OlMailItm.Attachments.Add (sWinZipFile)
    OlMailItm.Send

End Sub
 
You cant copy the db when using it but you can save it as a new db, then delete the copy once emailed.
 
Here is a copy of a file I have put together which zips and emails a db. Well any file, or a whole folder. Have a look it might be helpful for you.

John
 

Attachments

Here is a copy of a file I have put together which zips and emails a db. Well any file, or a whole folder. Have a look it might be helpful for you.

John

i assume you are talking about the fileopensave module in there, but i can't make heads or tails as to how it would work. why is the directory set to null in the function?
 
Patrick to get the db to work you have to enter some info first. Open the main menu and click on email addresses and enter the information for your emails and the address you want to zip files to go to, then click on dbOptions and turn on the email option, next click on files and folders and select the file or folder to backup and the location to backup to (another folder on your hard drive is good for this), then from the main menu click backup now and it should work.

The file opensave is purely for you to select a specific file to back up.

Under modules dBackup backs up the files or folders
Email_No_Outlook takes the zipped up file and emails it to your chosen address.

HTH
 

Users who are viewing this thread

Back
Top Bottom