ways to import excel to access

SKV

Active Member
Joined
Jan 7, 2009
Messages
255
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
 

Some videos you may like

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

SKV

Active Member
Joined
Jan 7, 2009
Messages
255
Got the way to develop Design -2.

Any pointers for Design 1???
 

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251
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
 

SKV

Active Member
Joined
Jan 7, 2009
Messages
255
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
 

xenou

MrExcel MVP, Moderator
Joined
Mar 2, 2007
Messages
16,687
Office Version
2013
Platform
Windows
I think if its the mechanism of importing to Excel you could try the transferspreadsheet method of the DoCmd object.
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,036
Messages
5,508,922
Members
408,701
Latest member
Ucchik7

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top