Results 1 to 4 of 4
  1. #1
    gammaman is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    56

    getting run-time error 7874: cannot find object select...

    When I run the following, I get run-time error 7874 cannot find object select...




    Sub Import()


    DoCmd.SetWarnings False


    'DoCmd.DeleteObject acTable, "test"


    DoCmd.SetWarnings True


    'DoCmd.TransferText acImportDelim, , "test", "C:\Users\Matthew\Desktop\test.txt", True


    DoSql


    End Sub



    Sub DoSql()


    Dim strSQL As String




    strSQL = "SELECT test.[Contact First Name],test.[Contact Last Name] FROM test;"


    DoCmd.OpenQuery strSQL







    End Sub

  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,521
    I'm pretty sure the OpenQuery method requires the name of a saved query. Since I never let users in tables or queries, I'd open a form or report instead.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    gammaman is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    56
    Thanks for the quick reply. Maybe I am approaching this wrong. What I am really trying to do is populate a table with a comma delimited file. This is being done with
    Code:
     DoCmd.SetWarnings False
    DoCmd.DeleteObject acTable, "test"
    DoCmd.SetWarnings True
    DoCmd.TransferText acImportDelim, , "test", "C:\Users\Matthew\Desktop\test.txt", True
    Once the table has data, I want to run a query against it. I want to do everything in VB Macro so that everytime I open the database, the code auto-fires.

  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,521
    Well, if you want to open a query, save that one and open it by name.
    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. Replies: 1
    Last Post: 07-13-2012, 07:58 PM
  2. Replies: 4
    Last Post: 01-27-2012, 02:16 AM
  3. Replies: 1
    Last Post: 09-03-2011, 07:01 PM
  4. Replies: 7
    Last Post: 02-03-2011, 07:13 AM
  5. Run-time error '424': Object required
    By cowboy in forum Programming
    Replies: 18
    Last Post: 07-07-2010, 03:32 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