Results 1 to 2 of 2
  1. #1
    johnny1g is offline Novice
    Windows XP Access 2002 (version 10.0)
    Join Date
    Sep 2009
    Posts
    2

    import using Macro


    I have a database that is updated on a weekly basis. I use a macro to import the file. My problem is that each new file has a different name & I must change the name in the macro each time. Is there a way to set up a variable input to enter the file name to import

  2. #2
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    Steps

    1. Convert your macro into visual basic

    2. Edit the newly created module containing the vba

    3. Create a form and place a text box and a button on it

    4. in the text box enter the name of the fiel to import

    5. on the OnClick event of the command button copy the code from the module to here and replace the known file name with the control name.

    Example taken from converted macro

    DoCmd.TransferSpreadsheet acImport, 8, "tblImport", "fred", True, ""


    code placed on OnClick event of command button

    Code:
     
    Dim sFile As String
     
    sFile = Me.TextBox1.Value
     
        DoCmd.TransferSpreadsheet acImport, 8, "tblImport", sFile, True, ""
    David

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

Similar Threads

  1. Macro To Import CSV to ACCESS
    By csvivek in forum Import/Export Data
    Replies: 1
    Last Post: 12-07-2009, 01:49 PM
  2. Access Macro
    By Gargen in forum Access
    Replies: 0
    Last Post: 09-14-2009, 09:13 AM
  3. Macro to Run RemoveFilter/Sort
    By Ryan in forum Access
    Replies: 0
    Last Post: 08-30-2009, 01:41 AM
  4. error in macro
    By nawaray in forum Access
    Replies: 0
    Last Post: 02-10-2009, 12:06 PM
  5. Macro for Indexed Value
    By jversiz in forum Access
    Replies: 0
    Last Post: 10-19-2007, 01:16 PM

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