Results 1 to 10 of 10
  1. #1
    wheddingsjr is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jan 2017
    Posts
    26

    Trying to create a If and Statement


    Hi all

    I am new to the forum and have a problem I was hoping someone could help me with. I have a table that I am trying to write an if statement for. Please see sample below. The idea is to populate the "Y/N" column by comparing the "MEMNO" and the "BEGDATE" and determine whether or not there is both a "SICK" and "PREVENTIVE" type for the same MEMNO on the same BEGDATE. Any suggestions would be appreciated. Thanks in advance.

    MEMNO BEGDATE SERVCODN TYPE Y/N
    ABC 01/11/16 99395 SICK
    ABC 01/11/16 99213 PREVENT
    ABC 01/11/16 99213 PREVENT
    ABC 01/11/16 99213 PREVENT
    DEF 05/31/16 99397 SICK
    DEF 05/31/16 99213 PREVENT
    GHI 02/16/16 99397 SICK
    GHI 02/16/16 99213 PREVENT
    MNOP 02/29/16 99214 PREVENT
    MNOP 02/29/16 99396 SICK
    QRS 04/04/16 99396 SICK
    QRS 04/04/16 99213 PREVENT
    TUV 01/29/16 99396 SICK
    TUV 01/29/16 99214 PREVENT
    XYZ 04/29/16 99397 SICK
    XYZ 04/29/16 99213 PREVENT
    ABC1 02/03/16 99396 SICK
    ABC1 02/03/16 99213 PREVENT

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Query1 - all "SICK"
    Query2 - all PREVENTATIVE
    Query3 - join 1 and 2 on MemNo and BegDate - those are the ones that have both.

  3. #3
    wheddingsjr is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jan 2017
    Posts
    26
    Thanks aytee111

    I created both queries and attempted to create the third but I am not sure which one to use. Sorry but I am rather new to access and I can do simple queries but this is a bit complex for me. So I join the two queries and to pull the data I need to do what?

    Thanks

    wheddingsjr

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    In the third query, bring in query1 and query2. "Join" means to link the fields, i.e. drag MemNo in query1 to MemNo in query2, that is a join. Do the same for BegDate. Now you have two sets of data, in the query fields add the fields that you want to show in the results.

  5. #5
    wheddingsjr is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jan 2017
    Posts
    26
    Thanks again... I know about the join...but are you saying that the third query should be an update query, with the Memno and the Begdate joined....bring the Y/N field in query 1 to and update that dataset and then do it again using the query 2 fields?

  6. #6
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Forgot about the updating! Bring in the table as well and join it in the same way. Then update the Y/N on the table.

  7. #7
    wheddingsjr is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jan 2017
    Posts
    26
    ahhh..ok...I thought that was what I should do but wanted to double check...thanks a bunch

  8. #8
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Make a copy of the table before you run it, then make sure that the correct records are being updated.

  9. #9
    wheddingsjr is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jan 2017
    Posts
    26
    wow...thanks aytee111..it worked PERFECTLY!!!!

  10. #10
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Glad to be of service.

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

Similar Threads

  1. Replies: 11
    Last Post: 04-29-2015, 01:38 PM
  2. Replies: 2
    Last Post: 03-26-2015, 08:29 PM
  3. if statement in sql statement, query builder
    By 54.69.6d.20 in forum Access
    Replies: 4
    Last Post: 09-11-2012, 07:38 AM
  4. Replies: 3
    Last Post: 07-10-2012, 05:23 AM
  5. Replies: 7
    Last Post: 08-17-2011, 01:49 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