Results 1 to 5 of 5
  1. #1
    smalljaws is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    3

    Combining multiple update queries

    Hello all, I am new to Access with very basic understanding of the program and databases in general. I need to change the values in a field (Trans) based on date (LocDate). There are roughly 20 values with thousands of records that need updating using different dates for each. I can do this individually with the query builder, but it seems there should be a way to combine these queries. Below are three of the individual queries, how would I go about combining these into one routine? Thanks.

    UPDATE LocData SET LocData.Trans = 2.5
    WHERE (((LocData.Trans)=2) AND ((LocData.LocDate)>#3/19/2014#));



    UPDATE LocData SET LocData.Trans = 3.5
    WHERE (((LocData.Trans)=3) AND ((LocData.LocDate)>#4/1/2014#));

    UPDATE LocData SET LocData.Trans = 4.5
    WHERE (((LocData.Trans)=4) AND ((LocData.LocDate)>#4/8/2014#));

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Does this UPDATE have to be done regularly or is this a one-time effort? 20 values so I guess that means 20 different criteria? That's too much for an IIf expression. Could possibly write a function that could be called by a single UPDATE action.

    UPDATE LocData SET Trans = GetData([Trans], [LocDate]);

    Now build the GetData function. Use Select Case or If Then Else structure.
    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
    smalljaws is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    3
    Quote Originally Posted by June7 View Post
    Does this UPDATE have to be done regularly or is this a one-time effort? 20 values so I guess that means 20 different criteria? That's too much for an IIf expression. Could possibly write a function that could be called by a single UPDATE action.

    UPDATE LocData SET Trans = GetData([Trans], [LocDate]);

    Now build the GetData function. Use Select Case or If Then Else structure.
    Yes, 20 different criteria. It will need to be run three or four times this year. I don't know SQL so I'm not sure if what you are suggesting would require more effort than just building and executing the 20 individual updates a few times this year? I was planning to do just that, but thought I would check to see if there was an easy way to combine the queries. Thanks for the response.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    A VBA procedure is the only option I can see. The custom function I describe is one possibility.

    The complication I see is that the function will have to be edited for each run because the date criteria will change. Or is the date criteria really important? It actually looks like you just want to add 0.5 to each Trans 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
    smalljaws is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    3
    Unfortunately, the date is very important. The trans values only after a specific date.

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

Similar Threads

  1. Replies: 7
    Last Post: 10-07-2013, 01:57 PM
  2. Replies: 2
    Last Post: 09-13-2012, 04:09 AM
  3. Combining multiple queries into one
    By kagoodwin13 in forum Queries
    Replies: 1
    Last Post: 03-27-2012, 01:29 PM
  4. Combining 3 update queries for a single table
    By Grahamiwa in forum Queries
    Replies: 1
    Last Post: 05-13-2011, 02:35 PM
  5. Combining like update queries
    By xcr800man in forum Queries
    Replies: 2
    Last Post: 05-20-2008, 08:36 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