Results 1 to 5 of 5
  1. #1
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486

    If statement only works one way


    I am trying to create an if statement that says "If box is checked then uncheck it, If box is unchecked then check it"

    Here is my code

    Code:
    FAvar = Me.BillingInvoiceID
    MsgBox "the Billing Invoice ID is " + FAvar
    
    
    Dim qd As DAO.QueryDef
    Dim rs As DAO.Recordset
    
    
    If Me.CTB = False Then
    
    
    Set qd = CurrentDb.QueryDefs("q_MarkCTB")
    qd!Param1 = FAvar
    
    
    qd.Execute dbFailOnError
    Me.Requery
    
    
    ElseIf Me.CTB = True Then
    
    
    Set qd = CurrentDb.QueryDefs("q_UnMarkCTB")
    qd!Param1 = FAvar
    Me.Requery
    
    
    End If
    I have also tried it as a regular IF, not ElseIf, and the result is the same. The first one works but the second one does not.
    Thanks
    Last edited by tagteam; 09-27-2022 at 09:55 AM.

  2. #2
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    229
    Your are missing the second qd.Execute.

  3. #3
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    Ouch , that hurts.

    Sorry, can't believe i didn't see that.

    Thanks for the wakeup

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Please post code, especially longer snips, between CODE tags to retain indentation and readability.
    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
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    ok, have done and will try to remember for the future

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

Similar Threads

  1. CASE Statement(s) to Update RS... works partially
    By skydivetom in forum Programming
    Replies: 13
    Last Post: 07-10-2021, 12:22 PM
  2. Replies: 10
    Last Post: 10-11-2016, 02:39 AM
  3. Replies: 8
    Last Post: 04-23-2015, 06:12 AM
  4. Replies: 7
    Last Post: 04-01-2014, 03:38 PM
  5. Replies: 6
    Last Post: 03-26-2013, 12:17 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