Results 1 to 6 of 6
  1. #1
    jmccon is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2015
    Posts
    12

    Passing a Parameter in a query to update Linked Table

    I have a linked table tblHome which is stored in a Sql Server DB and I want to create a form with 3 fields in it i.e. fieldA, fieldB, and FieldC in it and a button.


    I want to add values to fields fieldA and fieldB and fieldC and when I click the button I want the value in fieldA to update any records in the linked table tblHome which contains the values in fields fieldB and FieldC.

    Anyone know how to do this?

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    1. Make a query of tblHome using fields B & C as criteria - so that the result is always the correct record set - name that something like 'BCrecords'

    2. then you make an Update query using BCrecords as 1 table in query design - joined to the tblHome by the unique ID field; and putting field A from the form as the value to update into the table

    of course your permission to write to SQL Server is presumed......

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Simplest is probably to create an update query that uses the 3 textboxes in the appropriate places, then execute that query from your button (OpenQuery).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  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,530
    Oops, typed too slowly. It can be done in a single query I believe.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    jmccon is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2015
    Posts
    12
    Thanks for your reply pbaldy.
    Have you any examples of how to do this query that you say?

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    UPDATE TableName
    SET FieldA = <FormReference>
    WHERE FieldB = <FormReference> AND FieldC = <FormReference>
    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. Passing parameter from form to query
    By rhubarb in forum Forms
    Replies: 3
    Last Post: 05-03-2015, 10:29 AM
  2. Passing textbox value into sql query parameter
    By gustavoavila in forum Access
    Replies: 7
    Last Post: 04-23-2014, 04:00 PM
  3. Replies: 1
    Last Post: 02-08-2012, 04:50 PM
  4. Replies: 2
    Last Post: 08-14-2011, 08:35 PM
  5. Replies: 1
    Last Post: 01-22-2011, 12:23 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