Results 1 to 3 of 3
  1. #1
    Dieneces is offline Novice
    Windows XP Access 2007
    Join Date
    May 2012
    Posts
    3

    query to update columns based on values on other specific columns and values...

    Hello all experts,

    I'm new to access (use excel but in this case the amount of data is to big...) and I need to do something like this:

    I have a database with the following configuration:

    ID DATE HOUR NAME fullNAME VALUE RES1 RES2 RES3 00H 01H 02H 03H 04H 05H .... TO 24H
    1 09-05-2012 0 Car1 BIGCAR1 50 0 0 0
    2 09-05-2012 1 Car2 BIGCAR2 45.5 0 1 1
    3 09-05-2012 0 Car3 BIGCAR3 20.7 1 1 0
    4 09-05-2012 3 Car3 BIGCAR3 68.5 0 0 0
    5 09-05-2012 1 Car4 BIGCAR4 68.5 0 1 0
    6 09-05-2012 5 Car2 BIGCAR2 68.5 0 0 1
    7 09-05-2012 1 Car1 BIGCAR1 68.5 0 1 0
    8 09-05-2012 4 Car2 BIGCAR2 68.5 1 0 0
    9 09-05-2012 1 Car4 BIGCAR4 68.5 0 0 0



    What I need is to insert thexample.txte value from res1,res2 or res3 (if any of the 3 have 1 then the new value is 1, else is 0) in the hours columns (00h to 23h) based on the HOUR column.
    So it would become something like this:

    ID DATE HOUR NAME fullNAME VALUE RES1 RES2 RES3 00H 01H 02H 03H 04H 05H .... TO 24H
    1 09-05-2012 0 Car1 BIGCAR1 50 0 0 0 0
    2 09-05-2012 1 Car2 BIGCAR2 45.5 0 1 1 1
    3 09-05-2012 0 Car3 BIGCAR3 20.7 1 1 0 1
    4 09-05-2012 3 Car3 BIGCAR3 68.5 0 0 0 0
    5 09-05-2012 1 Car4 BIGCAR4 68.5 0 1 0 1
    6 09-05-2012 5 Car2 BIGCAR2 68.5 0 0 1 1
    7 09-05-2012 1 Car1 BIGCAR1 68.5 0 1 0 1
    8 09-05-2012 4 Car2 BIGCAR2 68.5 1 0 0 1


    9 09-05-2012 1 Car4 BIGCAR4 68.5 0 0 0 0


    I know I can try a TRANSFORM, the thing is that I dont want to change the layout... I tried some basic querys but in this case I thing a much more complicated programming is required...

    Could please someone point me in the right direction?

    example file formatted with notepad++

    Thanks for any help
    Last edited by Dieneces; 05-17-2012 at 03:54 PM.

  2. #2
    Dieneces is offline Novice
    Windows XP Access 2007
    Join Date
    May 2012
    Posts
    3
    tried to a query like this:

    Update 00H to 1 if HOUR = 0 and RES1=1 or RES2=1 or RES3=1

    but no joy... any way I think that the idea is basically on that criteria...

  3. #3
    Dieneces is offline Novice
    Windows XP Access 2007
    Join Date
    May 2012
    Posts
    3
    Ok the original SQL query that I made was right. Its just a simple SQL query: UPDATE databasename SET 00H=1 WHERE hour=0 AND RES1=1 OR RES2=1 OR RES3=1;

    The problem is that when I tried to run the query I mistype one of the fields... Now at home with a decent monitor (and not a 10 years old psychedelic laptop) I found the error #)

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

Similar Threads

  1. Replies: 4
    Last Post: 05-14-2012, 10:15 AM
  2. Report based on combo box values as columns
    By sadozai in forum Reports
    Replies: 2
    Last Post: 12-09-2011, 04:40 PM
  3. Combining values of 2 columns into one string
    By LAazsx in forum Programming
    Replies: 1
    Last Post: 11-25-2010, 08:36 PM
  4. Replies: 1
    Last Post: 10-09-2009, 11:52 AM
  5. Replies: 1
    Last Post: 10-01-2009, 06:41 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