Results 1 to 9 of 9
  1. #1
    gstreichan is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Feb 2018
    Posts
    4

    Allow user to select a combobox value only if other fields (dates) are filled in

    Dears,



    I have a combobox on a form called "cbo_ProcStatus" and there are different values for selection. One of the values in this combobox is "Order placed". There are other fields (textboxes) on same form called: Order_Placed_Date, Contractual_Date and Revised_Date. The users must to fill these dates prior to selecting "Order placed" but different times they are not doing it.

    What I want to do is to only allow user to select "Order placed" value in combobox if Order_Placed_Date, Contractual_Date and Revised_Date have been entered. In case one of the dates have not been entered yet then a message may pop up informing user to fill up the date.

    Could someone help me on vba and event for getting it done?

  2. #2
    Join Date
    Apr 2017
    Posts
    1,792
    In form's OnCurrent event, set the combo disabled or locked when any of those other controls is empty, and enabled/unlocked when all of them are filled. Do same in AfterUpdate events of all those controls too.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Presumably there are other values they can choose. I'd use the before update event of the combo to test those controls if that select was made. More here, though this discusses the form level event the same concept applies:

    http://www.baldyweb.com/BeforeUpdate.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Join Date
    Apr 2017
    Posts
    1,792
    In case other selections must be available for user, all remains same, but instead of enabling/disabling the combo, you have to edit combo's RowSource property in same events.

  5. #5
    gstreichan is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Feb 2018
    Posts
    4
    Thanks for your reply. I use a similar code for one control. I want to prevent user to select the option "Order placed" (only) in combobox "cbo_ProcStatus" if Order_Placed_Date, Contractual_Date and Revised_Date have not been filled then a message should come up. However, if user does any other selection like e.g. "Cancelled", "No Order yet", etc, then it is not necessary to have all those dates filled out. Can you help?

  6. #6
    gstreichan is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Feb 2018
    Posts
    4
    Thanks for your reply. I use a similar code for one control. I want to prevent user to select the option "Order placed" (only) in combobox "cbo_ProcStatus" if Order_Placed_Date, Contractual_Date and Revised_Date have not been filled then a message should come up. However, if user does any other selection like e.g. "Cancelled", "No Order yet", etc, then it is not necessary to have all those dates filled out. Can you help?

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Have you tried the before update event? Basically:

    Code:
    If Me.ComboName = "Order placed" And (Not IsDate(Field1) Or Not IsDate(Field2)...) Then
      MsgBox "Must enter dates to select Order Placed"
      Cancel = True
      Me.ComboName .Undo
    End If
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    gstreichan is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Feb 2018
    Posts
    4
    Thank you so much!

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 08-08-2017, 03:14 PM
  2. Replies: 3
    Last Post: 04-25-2017, 07:09 AM
  3. Replies: 3
    Last Post: 01-15-2017, 10:25 AM
  4. How do I see only fields that are filled?
    By fabiobarreto10 in forum Forms
    Replies: 56
    Last Post: 01-01-2012, 09:51 PM
  5. Replies: 0
    Last Post: 10-14-2009, 02:44 AM

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