Results 1 to 9 of 9
  1. #1
    basmster is offline Novice
    Windows 10 Access 2013
    Join Date
    Jan 2016
    Posts
    5

    Update Query not executing (sql language included)

    I'm trying to update two fields in the [CorporateRetailerTbl] table, [Parent Company] and [Organization Name (DBA)]. I ONLY want these fields updated if Parent Company is Null. I want to update these fields to the value in [Organization Name (DBA)] in the [2015 Master Reg List] table. Here's the SQL:






    UPDATE [2015 Master Reg List]
    INNER JOIN CorporateRetailerTbl ON [2015 Master Reg List].[ID] = CorporateRetailerTbl.[ID]
    SET CorporateRetailerTbl.[Parent Company] = [2015 Master Reg List].[Organization Name (DBA)], CorporateRetailerTbl.[Organization Name (DBA)] = [2015 Master Reg List].[Organization Name (DBA)]
    WHERE (((CorporateRetailerTbl.[Parent Company]) Is Null));



    I'm only getting the null fields and nothing is filling them. Also, sidenote...the Organization Name field in the CorporateRetailer table previously had the right data in it. But I ran an Update query and that field's records were updated with the empty/null values from the Parent Company field. The opposite of what I wanted to do.

    Thanks for your help.

    Basmster

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,648
    First do a SELECT query to see if the records are correctly retrieved based on the JOIN and the WHERE.


    Advise not to use spaces and special characters/punctuation (underscore is exception) in naming convention.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    basmster is offline Novice
    Windows 10 Access 2013
    Join Date
    Jan 2016
    Posts
    5
    I did and the right records are retrieved. All of the null or blanks show in the datasheet view but then when I change it to an update query...they're still blank? I did an update query earlier and it worked fine..I don't know why I'm not getting it now.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,648
    I don't see anything wrong with the posted SQL.

    I would have to review your database. If you want to provide, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    are you actually running the update or just viewing the 'result' in the query window. The view will be of the records before the update is actually run, not what they will be updated to

  6. #6
    basmster is offline Novice
    Windows 10 Access 2013
    Join Date
    Jan 2016
    Posts
    5
    Good question Ajax. I did view it first and I tried it two ways because I always forget how the update query works. I switch the fields I put in "Field" and "Update To", viewed it both ways and then ran the update BOTH ways and both times instead of updating the fields with the correct values, it updated the wrong field with the null values! That's what I'm confused about. How could doing the update query two different ways produce the same result?

  7. #7
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    don't know. the code you posted originally will update the CorporateRetailerTbl table

  8. #8
    basmster is offline Novice
    Windows 10 Access 2013
    Join Date
    Jan 2016
    Posts
    5
    I'm trying to attach the accdb but I don't think it worked. Maybe the file is too big? The upload got to 100% but then nothing seemed to attach?

  9. #9
    basmster is offline Novice
    Windows 10 Access 2013
    Join Date
    Jan 2016
    Posts
    5
    Hey all. I figured out what I was doing wrong. I had to include the same Parent field twice--once for the filter condition and twice for the update to field. Thank you all for your help.

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

Similar Threads

  1. executing update query
    By deepucec9 in forum Queries
    Replies: 2
    Last Post: 10-27-2015, 10:02 AM
  2. Need Help executing an update in form
    By ismith in forum Forms
    Replies: 17
    Last Post: 01-20-2012, 08:42 AM
  3. Create Custom box before executing query
    By mailinsiddu in forum Access
    Replies: 1
    Last Post: 01-09-2012, 11:14 AM
  4. Language Issue in Access Query
    By somnath in forum Queries
    Replies: 2
    Last Post: 09-07-2011, 10:31 AM
  5. Executing Query to Excel?
    By objNoob in forum Programming
    Replies: 1
    Last Post: 03-17-2010, 04:59 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