Results 1 to 4 of 4
  1. #1
    Darkmatter5 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2012
    Posts
    11

    Update query with multiple part if statements

    I have a table where I have 5 columns, (BatteryL1, BatteryL2, BatteryR1, BatteryR2 and BatterySize).

    I want to update BatterySize, with a value if any one of the above listed columns contains a specific value using something like 'LIKE' in the query.

    For example:
    UPDATE Customers
    SET BatterySize=13
    WHERE BatteryL1 LIKE '%13%'
    OR BatteryL2 LIKE '%13%'
    OR BatteryR1 LIKE '%13%'
    OR BatteryR2 LIKE '%13%'
    OR BatterySize LIKE '%13%'

  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,929
    Appears to be non-normalized data structure.

    Saving calculated data is usually a bad idea. The calculation can be done when needed.

    What does data in those fields actually look like? Will those fields have other values than 13?

    The usual wildcard for Access is * character. Is this a split db and the backend is SQL? http://office.microsoft.com/en-us/ac...005188185.aspx
    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
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I agree in general with June7's comments. However, % is the wildcard if using an ADO recordset.

  4. #4
    Darkmatter5 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2012
    Posts
    11
    Yep, I just changed it to * and it's working. Thanks for the input.

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

Similar Threads

  1. Replies: 14
    Last Post: 05-07-2014, 05:11 PM
  2. Replies: 11
    Last Post: 01-21-2014, 10:51 AM
  3. How to use multiple IIf statements in a query
    By jabadoojr in forum Queries
    Replies: 4
    Last Post: 12-17-2012, 11:05 AM
  4. Msaccess query to update day part to 01
    By baba in forum Queries
    Replies: 1
    Last Post: 10-03-2012, 08:46 PM
  5. IIF Statements and Update Queries.
    By nicknicknick in forum Queries
    Replies: 1
    Last Post: 06-05-2011, 12:08 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