ways to import excel to access

SKV

Active Member
Joined
Jan 7, 2009
Messages
257
My business users dont know access at all so I need a easy way for them to import excel sheet to specific tables.

Planing to develop this functionality in one of the 2 ways

Design 1 -
I plan to have a a separate button for each file type. When a user press this button a small window should pop-up asking user to browse the file to import. Once user browse and selects the file, he press the import button which should trigger a query to append this data to an existing table.

Design 2 -
Similar to design 1 but instead of user browsing to search the file, there will be specific folders on C: for each file type where the user will put these files. then on the form all user has to do is hit the import button to import this data.

Please advice how to develop these designs.

Thanks
SKV
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Adapted from the Access Help...
Code:
Function GetXlFiles()
   ' Requires reference to Microsoft Office 11.0 or 12.0 Object Library.

   Dim fDialog As Office.FileDialog
   Dim varFile As Variant

   ' Set up the File Dialog.
   Set fDialog = Application.FileDialog(msoFileDialogFilePicker)

   With fDialog

      ' Allow user to make multiple selections in dialog box
      'Set to False if users will only be selecting one item
      .AllowMultiSelect = True
            
      ' Set the title of the dialog box.
      .Title = "Please select one or more files"

      ' Clear out the current filters, and add our own.
      .Filters.Clear
      .Filters.Add "Excel Workbooks", "*.XLS"
      .Filters.Add "All Files", "*.*"

      ' 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 our list box.
         For Each varFile In .SelectedItems
            'import the file into the database: code required here
            
         Next varFile
      Else
         MsgBox "You clicked Cancel in the file dialog box."
      End If
   End With
   Set fDialog = Nothing
End Function

Denis
 
Upvote 0
Thanks SyndeyGeek, I will check this code and I know it will good as its from you.

For right now, I am working with design -2 using Macro. However I need some help here too.

I am able to export my query result to excel but for each query a new file is created and I want Only 1 file for my selected queries. Any direction on this.

Also how can I have the exported file to be formatted and Pivoted during the export itself?

Thanks
SKV
 
Upvote 0
I think if its the mechanism of importing to Excel you could try the transferspreadsheet method of the DoCmd object.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top