Export

syah96

Registered User.
Local time
Today, 08:39
Joined
Jan 23, 2013
Messages
10
Hello, I am Access beginner and here my problem
I develop MS Acccess application which may used by more than one company branches. I want to make and export button to export the data which allow me to transfer the data from one computer to another. The computer will use same MS Access application (which mean same table structure). And button to import the data. Please help me.
 
I think what abbaddon is getting at is if the database is in a shared location you can store your tables in a second database and use linked tables in your front end locations.

If not, it's fairly easy to import/export an access table. Here is some sample code to bring up the FileDialog box to allow the user to select a file (TableName is the name of the table you are exporting):

Code:
Private Sub import_Click()
    Dim fDialog As Office.FileDialog
    Dim varFile As Variant
    Dim BackupFile as String
    
    'Set up the File Dialog.
    Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
    With fDialog
       'Allow only one file to be selected
       .AllowMultiSelect = False
             
       'Set the title of the dialog box.
       .Title = "Please select the backup file."
    
       'Clear out the current filters, and add our own.
       .Filters.Clear
       .Filters.Add "Access Databases", "*.accdb"
       'Set the default location
       .InitialFileName = Application.CurrentProject.Path
       
       'Show the dialog box. If the .Show method returns True, the
       'user picked at least one file. If the .Show method returns
       'False, the user clicked Cancel.
       If .Show = True Then
          'Loop through each file selected and add it to the list box.
          For Each varFile In .SelectedItems
             BackupFile = varFile
          Next
       End If
    End With

    DoCmd.TransferDatabase(acImport,,BackupFile,acTable,"TableName") 
End Sub

Just switch the "acImport" to "acExport" to export a table.
 
Last edited:
Sorry for late reply. Your code seem not working. I try to adjust but has error. And you right, that kinda what i try to do
 

Users who are viewing this thread

Back
Top Bottom