Results 1 to 3 of 3
  1. #1
    mreniff is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2020
    Posts
    41

    IIf or Case statement to run one of two macros

    Can anyone help with this issue?



    I need an iif or VBA/SQL case statement that runs a query based on the state of a checkbox on a form or a popup input box


    This is this is module conversion of the macro that updates_fake_flightpath_in_students_table. I need this process to programmably select between two choices.
    '
    '------------------------------------------------------------
    'Function updates_fake_flightpath_in_students_table()
    'On Error GoTo updates_fake_flightpath_in_students_table_Err


    'insert EXPL-CoD in student fake flightpath
    DoCmd.OpenQuery "selects and UPDATES flightpath EXPL-CoD students", acViewNormal, acEdit

    'iif([checkbox on form]=yes or [input box = yes], then run this query
    'DoCmd.OpenQuery "selects and UPDATES flightpath NO EXPL-HPP students", acViewNormal, acEdit

    'iif([Checkbox on a form]=no or [input box = no], then run this query
    DoCmd.OpenQuery "selects and UPDATES flightpath EXPL-HPP students", acViewNormal, acEdit ' allows EXPL-HPP to be scheduled separately from HC


    'then run rest of update queries
    ' DoCmd.OpenQuery "updates flightpath EXPL student records", acViewNormal, acEdit
    ' DoCmd.OpenQuery "make Student update temp table", acViewNormal, acEdit
    ' DoCmd.OpenQuery "updates flightpath in student records", acViewNormal, acEdit


    'updates_fake_flightpath_in_students_table_Exit:
    ' Exit Function


    'updates_fake_flightpath_in_students_table_Err:
    ' MsgBox Error$
    ' Resume updates_fake_flightpath_in_students_table_Exit


    'End Function

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    In future, please post code between CODE tags to retain indentation and readability

    Sounds like a simple If Then Else conditional 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
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,389
    You certainly don't need those iif functions. Use simple If as June7 suggests.

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

Similar Threads

  1. CASE STATEMENT or IF-ELSE-THEN? HELP
    By Shakenaw in forum Access
    Replies: 9
    Last Post: 06-08-2015, 11:24 AM
  2. SQL Statement using WHERE with CASE and CHECKBOX
    By jasonm in forum Programming
    Replies: 8
    Last Post: 04-14-2015, 07:45 AM
  3. Case Statement
    By RussH in forum Programming
    Replies: 1
    Last Post: 08-12-2013, 02:50 PM
  4. if or case statement and how
    By Dannat in forum Queries
    Replies: 1
    Last Post: 01-31-2012, 10:35 AM
  5. Case Statement Syntax
    By allenjasonbrown@gmail.com in forum Programming
    Replies: 1
    Last Post: 11-16-2010, 07:18 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