Results 1 to 3 of 3
  1. #1
    Ant_Snell is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2021
    Location
    UK
    Posts
    118

    Problems with my If, Then, Else statement

    I have the below code that is only working partially and have spent hours trying to fix to no avail, any help appreciated.

    The scenario is that I have a tick box [Actioned] When I tick it I want to run an Update query [Qry_Cancelled_Update_PO_Num] that enters the current date in the date used field of tbl_PO_Numbers. If the user made a mistake, then un-ticking should run the Update Query [Qry_Cancelled_Update_PO_Num_Remove] to remove the date.

    Both queries work independently perfectly but when running the code only the first part runs (entering the date) It is not removing the date if I untick the Actioned tick box.

    The code is attached to the on click property of the tick box



    Private Sub ACTIONED_Click()
    'DoCmd.SetWarnings False
    If IsNull(DLookup("[DateUsed]", "tbl_Order_Numbers")) Then
    DoCmd.OpenQuery "Qry_Cancelled_Update_PO_Num"
    Else
    DoCmd.OpenQuery "Qry_Cancelled_Update_PO_Num_Remove"
    End If
    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    if you are using a checkbox, then wheres the checkbox:

    Code:
    If chkBox.value Then DoCmd.OpenQuery "Qry_Cancelled_Update_PO_Num" Else DoCmd.OpenQuery "Qry_Cancelled_Update_PO_Num_Remove" End If


  3. #3
    Ant_Snell is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2021
    Location
    UK
    Posts
    118
    Ranman, thanks that worked and fixed it! Easy when you know how

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

Similar Threads

  1. After Update to Insert Into statement problems
    By d9pierce1 in forum Programming
    Replies: 4
    Last Post: 09-25-2019, 06:06 PM
  2. Replies: 3
    Last Post: 08-17-2015, 03:06 PM
  3. or statement problems
    By kalkap in forum Queries
    Replies: 6
    Last Post: 03-04-2014, 09:08 AM
  4. Replies: 11
    Last Post: 03-21-2012, 12:51 PM
  5. Problems with an If statement
    By slenish in forum Access
    Replies: 1
    Last Post: 03-10-2010, 09:23 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