Make a field Required based on data in another field. RRS feed

  • Question

  • I am using Access 2010. I have a field called [strDiagnosis] in an Access form. If there is a diagnosis in this field, I want to make [strDiagnosisCode] a required field.

    Thank you in advance!!

    Thursday, March 9, 2017 5:27 PM

All replies

  • You can use the Before Update event of the form for this:

    Private Sub Form_BeforeUpdate(Cancel As Integer)
        If Not IsNull(Me.strDiagnosis) And IsNull(Me.strDiagnosisCode) Then
            MsgBox "Please enter/select a diagnosis code!", vbExclamation
            Cancel = True
        End If
    End Sub

    Regards, Hans Vogelaar (

    Thursday, March 9, 2017 8:11 PM
  • Thank you so much!!!  It worked perfectly.
    Friday, March 10, 2017 2:46 PM