Results 1 to 4 of 4
  1. #1
    Phred is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2009
    Posts
    246

    Help with first SQL Pass Through Update query

    Access 2007 front end. Sql Server 2008 R2 back end. ODBC established. Linked tables. I am logged in as SA. I can see all table and all data. I can call up data. This is my first Access to SQL Server database and my first Update query. I wrote the query in Access Query builder. When it was grabbing the data I converted it to a SQL Pass Through Query and edited the SQL Statement so it was correct (I think) and placed it the After Update control of a Combo box. The Variables are calling the correct data as per the watches. I am not getting any error messages from the SQL Statement. But I get an error message when I execute the SQL statement.

    Code:
    Private Sub TownshipNM_AfterUpdate()
       On Error GoTo TownshipNM_AfterUpdate_Error
    
    Dim IntPropID As Integer
    Dim StrCountyNM As String
    Dim StrTownNO As String
    Dim StrTownNM As String
    Dim StrCycleNM As String
    Dim strVolNO   As String
    Dim strSQL As String
    
    IntPropID = Me!PropertyID
    StrTownNM = Me.[TownshipNM].[Column](0)
    StrTownNO = Me.[TownshipNM].[Column](1)
    StrCountyNM = Me.[TownshipNM].[Column](2)
    StrCycleNM = Me.[TownshipNM].[Column](3)
    strVolNO = Me.[TownshipNM].[Column](4)
    
    strSQL = "Update dbo.Property" & " SET County = '" & StrCountyNM & _
        "', TownshipNO = '" & StrTownNO & "', TownshipNM = '" & StrTownNM & _
        "', Cycle = '" & StrCycleNM & "', Volume = '" & strVolNO & "'" & _
        " WHERE PropertyID = ' & IntPropID & ' "
    
    DoCmd.RunSQL strSQL
    When I execute the RunSQL command I get the following error

    Error 3024 (Could not find file 'C:\Users\Phred\Documents\dbo.mdb'.)
    in procedure TownshipNM_AfterUpdate of VBA Document Form_DBO_Property

    I don't think it is directing the update to the SQL Server via ODBC. Do I need to direct it somehow to the SQL Server?

    It should be directed to the ODBC database K2

    Thanks

    Phred

  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
    What you're doing is not using a pass through query. If the table is linked, just refer to the linked table name.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Phred is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2009
    Posts
    246

    Solved

    Paul: Thanks that worked. Now I understand what you told me earlier about referencing everything within Access to the linked tables. In other words I get it now. Thanks, I will close this out.

  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
    Happy to help! Pass through queries are a great tool, just not always necessary.
    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. How do I update a Table from a Pass-Through Query
    By smc678 in forum Programming
    Replies: 6
    Last Post: 06-27-2013, 08:18 AM
  2. Update access table from a pass-through query
    By francesco in forum Access
    Replies: 3
    Last Post: 07-02-2012, 05:49 AM
  3. Troble with a pass through query
    By itm in forum Queries
    Replies: 2
    Last Post: 10-24-2011, 12:19 PM
  4. Pass-Through Query or ADO, is there a way?
    By Amber_1977 in forum Queries
    Replies: 3
    Last Post: 11-10-2010, 08:56 AM
  5. I want to automatically pass a value to a query
    By Slategrey252 in forum Queries
    Replies: 1
    Last Post: 10-01-2009, 05: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