Results 1 to 4 of 4
  1. #1
    Robbie MacKinnon is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    1

    using mdb files which are backed up hourly into zip files

    Hi,

    I am new to access and am seeking advice on how to deal with the the following:
    Every hour a zip file is created in an FTP folder. The zip file contains an .mdb access database file with any changes to the data since the last hours file.
    What is the best method to get access to connect to the content of the zip files and pick up the changes to the data?



    Thanks,

    Henry Robe.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,942
    First, have to extract the db from the zip.

    I have code that creates a zip and copies file into the zip. Here is my code to create zip (gstrBasePath is a global constant declared in another module, replace it with your file path, ex: "C:\path string here\"):

    'create empty zip folder
    'found this on web, no idea what the Print line does but if it isn't there, this won't work
    Open strZip For Output As #1
    Print #1, "PK" & Chr$(5) & Chr$(6) & String(18, 0)
    Close #1
    'copy file into zip folder
    Dim objApp As Object
    Set objApp = CreateObject("Shell.Application")
    'variable for source file doesn't seem to work in this line
    'also double parens not in original code but won't work without
    objApp.NameSpace((strZip)).CopyHere gstrBasePath & "Program\Editing\ConstructionExtract.accdb"

    I guess the reverse would be quite similar - open the zip and copy from zip to other folder. I could not get a variable to work in constructing the path of file to copy into zip (tested but not need in this case). Might be same issue with copying out of zip. Review http://www.ehow.com/how_6908798_extr...-file-vba.html

    Will the file name be different each time? If not, just set up links to the tables and each copy will replace the file. Otherwise, VBA code will have to set table links or just open connection to the db. Run INSERT SELECT and/or UPDATE sql actions.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    joanas is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    9
    hey thanks

    i tried this code and it seems to work ok

    Sub Zip_File()
    Dim strDate As String, DefPath As String
    Dim oApp As Object
    Dim FName, FileNameZip

    DefPath = CurrentProject.Path
    If Right(DefPath, 1) <> "\" Then
    DefPath = DefPath & "\"
    End If

    FileNameZip = "Path\MyFilesZip.zip"

    FName = "C:\Data\db1.mdb"

    'Create empty Zip File
    NewZip (FileNameZip)

    Set oApp = CreateObject("Shell.Application")

    oApp.NameSpace(FileNameZip).CopyHere FName

    MsgBox "You find the zipfile here: " & FileNameZip
    Set oApp = Nothing
    End Sub

    Sub NewZip(sPath)
    'Create empty Zip File
    Dim oFSO, arrHex, sBin, i, Zip
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    arrHex = Array(80, 75, 5, 6, 0, 0, 0, _
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
    For i = 0 To UBound(arrHex)
    sBin = sBin & Chr(arrHex(i))
    Next
    With oFSO.CreateTextFile(sPath, True)
    .Write sBin
    .Close
    End With
    End Sub

  4. #4
    joanas is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Posts
    9
    to add more files to the zip i just add this two lines:

    FName2 = "C:\Data\db2.mdb"

    oApp.NameSpace(FileNameZip).CopyHere FName2


Please reply to this thread with any new information or opinions.

Similar Threads

  1. PDF OLE files
    By sam1 in forum Access
    Replies: 0
    Last Post: 11-24-2011, 07:26 AM
  2. Attached Files
    By tcheck in forum Access
    Replies: 1
    Last Post: 08-11-2011, 09:46 PM
  3. Replies: 1
    Last Post: 02-21-2011, 09:55 PM
  4. Linking up two files
    By heidiffg in forum Access
    Replies: 0
    Last Post: 02-14-2011, 09:39 AM
  5. .ocx Files Errors
    By darshita in forum Import/Export Data
    Replies: 9
    Last Post: 12-07-2009, 07:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums