Results 1 to 6 of 6
  1. #1
    akeller is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Nov 2018
    Posts
    38

    Update Query modifying records it shouldn't.

    My update query is modifying the IncomingJobID_FK on previous records.


    It is taking the IncomingJobID_FK from a comobox on a form and updating that field on my first row when it shouldn't.
    It should ONLY update empty fields within rows that contain the IncomingJobID_FK .

    Any Ideas?

    Code:
    UPDATE tblIncomingJobJoin SET tblIncomingJobJoin.Claimed = "-1", tblIncomingJobJoin.InspectorID_FK = [Forms]![tblIncomingJobJoin1]![cboInspectorID_FK], tblIncomingJobJoin.MachineID_FK = [Forms]![tblIncomingJobJoin1]![cboMachineID_FK], tblIncomingJobJoin.CalSphereID_FK = [Forms]![tblIncomingJobJoin1]![cboCalSphereID_FK], tblIncomingJobJoin.Comments = [Forms]![tblIncomingJobJoin1]![txtComments]
    WHERE (((tblIncomingJobJoin.InspectorID_FK) Is Null) AND ((tblIncomingJobJoin.MachineID_FK) Is Null) AND ((tblIncomingJobJoin.CalSphereID_FK) Is Null) AND ((tblIncomingJobJoin.IncomingJobID_FK)=[Forms]![tblIncomingJobJoin1]![cboIncomingJobID_FK]));

  2. #2
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Is claimed really a text field ? You're setting it (or attempting to) to a text value "-1"

    I've reformatted your query to make it easier to see what's happening;
    Code:
    UPDATE tblIncomingJobJoin SET tblIncomingJobJoin.Claimed = "-1", 
    tblIncomingJobJoin.InspectorID_FK = [Forms]![tblIncomingJobJoin1]![cboInspectorID_FK], 
    tblIncomingJobJoin.MachineID_FK = [Forms]![tblIncomingJobJoin1]![cboMachineID_FK], 
    tblIncomingJobJoin.CalSphereID_FK = [Forms]![tblIncomingJobJoin1]![cboCalSphereID_FK], 
    tblIncomingJobJoin.Comments = [Forms]![tblIncomingJobJoin1]![txtComments]
    WHERE (((tblIncomingJobJoin.InspectorID_FK) Is Null) 
    AND ((tblIncomingJobJoin.MachineID_FK) Is Null) 
    AND ((tblIncomingJobJoin.CalSphereID_FK) Is Null) 
    AND ((tblIncomingJobJoin.IncomingJobID_FK)=[Forms]![tblIncomingJobJoin1]![cboIncomingJobID_FK]));
    I'm not sure this makes sense, or at least your form names aren't helping.
    Having a form called tblIncomingJobJoin1 is at the very least confusing... Especially to outsiders looking in.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    akeller is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Nov 2018
    Posts
    38
    Quote Originally Posted by Minty View Post
    Is claimed really a text field ? You're setting it (or attempting to) to a text value "-1"

    I've reformatted your query to make it easier to see what's happening;
    Code:
    UPDATE tblIncomingJobJoin SET tblIncomingJobJoin.Claimed = "-1", 
    tblIncomingJobJoin.InspectorID_FK = [Forms]![tblIncomingJobJoin1]![cboInspectorID_FK], 
    tblIncomingJobJoin.MachineID_FK = [Forms]![tblIncomingJobJoin1]![cboMachineID_FK], 
    tblIncomingJobJoin.CalSphereID_FK = [Forms]![tblIncomingJobJoin1]![cboCalSphereID_FK], 
    tblIncomingJobJoin.Comments = [Forms]![tblIncomingJobJoin1]![txtComments]
    WHERE (((tblIncomingJobJoin.InspectorID_FK) Is Null) 
    AND ((tblIncomingJobJoin.MachineID_FK) Is Null) 
    AND ((tblIncomingJobJoin.CalSphereID_FK) Is Null) 
    AND ((tblIncomingJobJoin.IncomingJobID_FK)=[Forms]![tblIncomingJobJoin1]![cboIncomingJobID_FK]));
    I'm not sure this makes sense, or at least your form names aren't helping.
    Having a form called tblIncomingJobJoin1 is at the very least confusing... Especially to outsiders looking in.
    The Claimed field is a Yes/No field. The "-1" actually does what it's supposed to. Yeah, I know the naming sucks, I plan on updating once I get this issue figured out.

  4. #4
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Okay - so if the query looks right , change it to a select and see if it pulls the right records?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #5
    akeller is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Nov 2018
    Posts
    38
    Figured it out. It had nothing to due with my query but was because of a bound combox on a form. I just changed it to unbound and set the row source as the value from a parent forms combo.

    Thanks for you help

  6. #6
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Glad you sorted it - obviously me just being near the thread steered you in the right direction !
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

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

Similar Threads

  1. Replies: 3
    Last Post: 08-14-2016, 02:18 PM
  2. Access adds records it shouldn't add?
    By supertanno in forum Access
    Replies: 1
    Last Post: 11-07-2011, 09:57 AM
  3. Update Query: Modifying Data Using Top Values
    By William McKinley in forum Queries
    Replies: 1
    Last Post: 11-30-2010, 02:20 PM
  4. Modifying Update Query
    By James Elvin in forum Queries
    Replies: 0
    Last Post: 10-14-2008, 09:07 AM
  5. Replies: 0
    Last Post: 04-26-2008, 09:59 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