Make a field compulsary subject to status

  • Thread starter Thread starter RitchieJHicks
  • Start date Start date
R

RitchieJHicks

I have 4 file status' - ACTIVE, PENDING, SOLS and REJECTED.

I wish to make a field called DiaryDate compulsary if Active or Pending is
selected.

Could someone please advise me how to code this?

Thank you.
 
Use the Form Before Update Event to test for the condition and cancel the
update if the date is missing:

Private Sub Form_BeforeUpdate(Cancel As Integer)

Dim strMsg As String

If Me.Status = "ACTIVE" Or Me.txtStatus = "PENDING" Then
If IsNull(Me.DairyDate) Then
strMsg = "Dairy Date Is Required When Status Is " & Me.Status
ElseIf Not IsDate(Me.DairyDate) Then
strMsg = "Dairy Date Is Not A Valid Date"
End If
If Len(strMsg) > 0 Then
MsgBox strMsg, vbExclamation
Cancel = True
Me.DairyDate.SetFocus
End If
End If
End Sub
 
Thanks, but I tried this (replacing "status" with my field name of
"FileStatus" but I got a "compile error". What might have caused this please?
 
Post the code as you wrote it and identify exactly what was highlighted when
you got the compile error, please.
 
Hi,

on the line If Me.Status = "ACTIVE" Or Me.txtStatus = "PENDING" Then, the
..Status is highlighted and the message is "Compile Error - Method or data
member not found"

Thanks,
Ritchie.
 
I thought you said you had changed the code from Status to FileStatus because
that is the name of your control?
It needs to be whatever the name of the control is that you are evaluating.
 
Back
Top