Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2013
    Location
    Milwaukee, WI, USA
    Posts
    5

    Update Query - Should be simple,but it's been far too long.

    I haven't run this since 2008 or so, and I just updated to Office265 and Access 2013. I can't figure out what the issue is... And I'm very rusty. Can anyone look at what I have and make a suggestion on how to fix it?



    Thanks in advance,
    Tom





    Two tables. Just trying to update the sex in one table with the values from the other, if the name fields match at least the first 8 characters. Simple gender assignment.

    TABLE 1
    F2013_Batch1
    fname
    sex

    TABLE2
    tblCleanupGender
    CU1Name
    CUsex


    This is the SQL Access generates based on the tables.

    UPDATE tblCleanupGender, F2013_Batch1 AS F2013_Batch1_1 SET F2013_Batch1_1.sex = [tblCleanupGender].[CUsex]
    WHERE (((F2013_Batch1_1.fname)=[tblCleanupGender].[CU1Name]));

  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
    52,822
    Try using Left() function.

    UPDATE tblCleanupGender, F2013_Batch1 AS F2013_Batch1_1 SET F2013_Batch1_1.sex = [tblCleanupGender].[CUsex]
    WHERE (((Left(F2013_Batch1_1.fname,8))=Left([tblCleanupGender].[CU1Name],8)));
    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
    Join Date
    Sep 2013
    Location
    Milwaukee, WI, USA
    Posts
    5
    No luck. It runs, but is selecting 0 (zero) rows.



    Quote Originally Posted by June7 View Post
    Try using Left() function.

    UPDATE tblCleanupGender, F2013_Batch1 AS F2013_Batch1_1 SET F2013_Batch1_1.sex = [tblCleanupGender].[CUsex]
    WHERE (((Left(F2013_Batch1_1.fname,8))=Left([tblCleanupGender].[CU1Name],8)));

  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
    52,822
    It does work for me.

    Why do you need to limit to 8 characters? You want Martin and Martinson to get the same value?
    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
    Join Date
    Sep 2013
    Location
    Milwaukee, WI, USA
    Posts
    5
    Essentially, yes. But, I'm working with first names. I'm assigning gender based on first name, so I want it to recognize "Johnathan" is male, but the control file only has "Johnatha".

    The control file creates the limit of 8 characters, and I didn't create the control file.




    Quote Originally Posted by June7 View Post
    It does work for me.

    Why do you need to limit to 8 characters? You want Martin and Martinson to get the same value?

  6. #6
    Join Date
    Sep 2013
    Location
    Milwaukee, WI, USA
    Posts
    5
    Hang on... I received dirty data. I'm cleaning it up and testing again.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Careful with assumptions. My niece is Kelly and my nephew is Shawn. My uncle was June and another uncle was Meredith.

    Ever hear of Leslie Nielsen, Leslie Caron?
    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.

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

Similar Threads

  1. Replies: 1
    Last Post: 05-08-2013, 07:08 PM
  2. Replies: 19
    Last Post: 11-01-2012, 08:03 AM
  3. Simple Update Query
    By guygodwin in forum Queries
    Replies: 1
    Last Post: 02-16-2012, 10:59 PM
  4. Simple Update SQL
    By DADAZHU in forum Programming
    Replies: 4
    Last Post: 12-08-2011, 05:22 PM
  5. Update Query too long
    By ack9f in forum Queries
    Replies: 3
    Last Post: 04-26-2010, 12:11 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