Results 1 to 3 of 3
  1. #1
    dhicks is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jun 2017
    Posts
    36

    MsgBox for multiple scenarios

    Hello,



    I have a check box on my form that needs to display one of three messages, depending on certain criteria. Currently, I have these 3 scenarios:

    1. A message displays if the check box is checked.

    2. A message displays if a particular Date field is Null.

    3. A message displays if the check box is checked and a particular Date field is Null.

    The way I have my code set up currently, if scenario 3 is true, then ALL 3 messages pop up, one after the other. How can I modify the code below to check for each scenario and only display the message that meets that particular criteria?

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Private Sub Form_Current()


    If Checked_Out_YN = True Then
    MsgBox "This Item is currently Checked Out"
    End If

    If DCount("*", "qryMsgBoxCriteria", "Item='" & Me!Item & "' And IsNull(Actual_Pickup_Date)") Then
    MsgBox "There is an active Reservation on this item, check for potential Date conflicts.", , "OPEN RESERVATION!"
    End If

    If DCount("*", "qryMsgBoxCriteria", "Item='" & Me!Item & "' And IsNull(Actual_Pickup_Date)") And Checked_Out_YN = True Then
    MsgBox "There is an active Reservation on this item, check for potential Date conflicts. This Item is also currently Checked Out.", , "OPEN RESERVATION!"
    End If

    End Sub

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Thanks!!

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Start your IF with item 3 and use "ELSE" between each.

  3. #3
    dhicks is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jun 2017
    Posts
    36
    Too easy, if it was a snake it would have bit me. Thanks Aytee!!

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

Similar Threads

  1. vba MsgBox for some but not all
    By BusDriver3 in forum Macros
    Replies: 18
    Last Post: 12-15-2016, 09:33 PM
  2. Replies: 5
    Last Post: 09-30-2015, 04:28 PM
  3. Replies: 24
    Last Post: 03-20-2013, 06:58 PM
  4. MsgBox
    By Mtyetti in forum Forms
    Replies: 4
    Last Post: 07-27-2011, 01:51 PM
  5. Use Case Scenarios
    By scott.weppler in forum Access
    Replies: 0
    Last Post: 05-31-2009, 12:15 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