Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2009
    Posts
    13

    Unanswered: command button to open "Import file" dialogue box

    I have a database that requires multiple tables to be imported weekly from a single XML file (the XML file name is new each week).
    I would like to have a button on a form that opens the Import File dialogue box so that a user can just go find that week's file and import it.
    I have tried and tried but I cannot figure this out...can anyone help? Thank you! PS - I'm using Access 2003.

    Thank you!!!

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6

  3. #3
    Join Date
    Jul 2009
    Posts
    13

    I'm still lost...

    Yes, I've been trying to make that work but I'm still having problems with the import part of it. I can get the Open file dialogue box to open, and I can select my XML file, but I don't know how to import it from there.
    Part of my problem is that I don't know any programming, so I can cut and paste code but I actually understand very little of it. Is there any way someone could walk me through it?
    Thanks so much.

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Here's an example:

    Code:
      Dim strPath                 As String
    
      strPath = OpenCommDlg("Import Files", "", -1, "\\InitialPathHere")
    
      If Len(strPath) > 0 And Right(strPath, 3) = "xls" Then
        'empty table
        CurrentDb.Execute "DELETE * FROM Excel401k"
        'import data from selected file
        DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Excel401k", strPath, True
    
      End If
    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •