Results 1 to 4 of 4
  1. #1
    diane802 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    92

    Button Command to Transfer Spreadsheet

    Hi -

    I am trying to write the vba code so that when a button is pressed, it will do the command of "TransferSpreadsheet" and import that spreadsheet data and replace a current existing table.



    However, the file name can change each time, so I want it to prompt the file name, and open up the dialog box to allow the user to browse for the file name.

    How do I do that? Can I just do that as a macro, or does it need to be vba?

  2. #2
    llkhoutx is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Location
    Houston, Texas USA
    Posts
    373
    You need to prompt the user for the file name, then use that response in your TransferSpreadsheet command.

    me.txtArgument = InputBox("Input the name of the file")
    then

    docmd.transferspreadsheet ...,Me.txtArgument,...


  3. #3
    diane802 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    92
    how can I have it though so that its not typing in the name, but instead browsing for it through a pop-up window?

  4. #4
    llkhoutx is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Location
    Houston, Texas USA
    Posts
    373
    Why not use a combo box on your form instead of on a popup. If you use a popup, you'll have to store the value on the form unless you also call Transferspreadsheet from the popup. I recommend that you use a combo box on you form.

    docmd.transferspreadsheet ...,Me.ComboboxName,...

    or
    docmd.transferspreadsheet ...,Me.textboxName,...

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

Similar Threads

  1. Transfer SpreadSheet Command and Rename
    By fintan06 in forum Import/Export Data
    Replies: 2
    Last Post: 10-15-2009, 08:00 AM
  2. how to disable command button
    By archie in forum Access
    Replies: 1
    Last Post: 08-27-2009, 11:11 PM
  3. Command Button Help!
    By arthura in forum Programming
    Replies: 3
    Last Post: 06-30-2009, 12:55 PM
  4. Duplicate command button
    By brettg in forum Database Design
    Replies: 1
    Last Post: 08-04-2008, 04:16 AM
  5. File path name using Transfer spreadsheet
    By JohnN in forum Import/Export Data
    Replies: 0
    Last Post: 11-14-2005, 06:57 AM

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