Results 1 to 2 of 2
  1. #1
    Suzfitzy is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    1

    Field required based on another field


    I have a form that has a field "Discharge Date" If this field has a date I want other fields to be required.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    I do my checks via code (not in the field property)
    All in 1 place, easier to change.
    don't let the form close until the reqd fields are filled...
    usage:


    Private Sub Form_Unload(Cancel As Integer)
    cancel = not IsValidForm()
    End Sub



    Code:
    Private Function IsValidForm() As Boolean
    Dim vMsg
    Select Case True
       Case IsNull(cboWeekOf)
          vMsg = "Date field missing"
       Case IsNull(cboUser)
          vMsg = "User name is missing"
       Case IsNull(txtEmail)
          vMsg = "Email field is missing"
    End Select
    If vMsg <> "" Then MsgBox vMsg, vbCritical, "Required Field"
    IsValidForm = vMsg = ""
    End Function

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

Similar Threads

  1. Replies: 4
    Last Post: 06-29-2015, 01:56 PM
  2. Replies: 10
    Last Post: 06-18-2015, 11:52 AM
  3. Replies: 3
    Last Post: 01-09-2015, 05:48 PM
  4. Replies: 1
    Last Post: 12-07-2012, 02:14 AM
  5. Replies: 3
    Last Post: 01-15-2012, 02:46 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