Results 1 to 4 of 4
  1. #1
    dada is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    40

    Setting a variable on a table name after importing

    Here is my code:



    DoCmd.SetWarnings (False)
    Dim sql As String

    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, TableName.Value, TxtPath.Value, False, "A7:H1000"

    sql = "INSERT into DTR(EmpNum, EmpName, eDate, eDay, FIN, FOUT, LIN, LOUT) Select F1, F2, F3, F4, F5, F6, F7, F8 from '" & TableName & "'"
    DoCmd.RunSQL (sql)

    NOTE: TableName and TxtPath are Textbox in a form.
    ERROR: I got some problems with the code above which i colored the font as red. any idea how this logic can be done? What I'm trying to do is after importing an excel file, it will then copy the values from the table created from importing to the DTR table.. please help..

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You're on the right track; you don't want the single quotes around the table name.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    dada is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    40
    awesome! thanks dude!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    No problemo.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. SELECT INTO variable table name
    By Ian P in forum Queries
    Replies: 2
    Last Post: 05-29-2010, 12:49 AM
  2. Replies: 2
    Last Post: 05-09-2010, 04:10 AM
  3. Variable Table Names in a Module
    By Jessica in forum Modules
    Replies: 1
    Last Post: 04-19-2010, 07:38 PM
  4. Assign and call variable from table
    By smikkelsen in forum Access
    Replies: 7
    Last Post: 04-01-2010, 09:38 AM
  5. Need help in importing table
    By sdondeti in forum Access
    Replies: 6
    Last Post: 11-16-2009, 09:38 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