shieldsco
asked on
How do I require a user to enter data in a field?
I have a form that I want to require users to enter data. If the Scheduled Appt field on the form equals yes then require the user to enter the date and time in the App Date/Time field. If the scheduled Appt field equals No then the App Date/Time must be Null. See attached
Scheduled-App.docx
Scheduled-App.docx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I used the following code with no effect: Private Sub AppDtTime_BeforeUpdate(Can cel As Integer)
If SchAppt Then
If Trim("" & AppDtTime) = "" Then
MsgBox "An Appt Date and Time is required." & vbCrLf & vbCrLf & "Press <ESC> to undo your changes"
Cancel = True
End If
Else
If Trim("" & AppDtTime) = "" Then
Else
MsgBox "An Appt Date and Time is not allowed." & vbCrLf & vbCrLf & "Press <ESC> to undo your changes"
Cancel = True
End If
End If
End Sub
If SchAppt Then
If Trim("" & AppDtTime) = "" Then
MsgBox "An Appt Date and Time is required." & vbCrLf & vbCrLf & "Press <ESC> to undo your changes"
Cancel = True
End If
Else
If Trim("" & AppDtTime) = "" Then
Else
MsgBox "An Appt Date and Time is not allowed." & vbCrLf & vbCrLf & "Press <ESC> to undo your changes"
Cancel = True
End If
End If
End Sub
Put the code in the form BeforeUpdate event procedure not the AppDtTime control BeforeUpdate event procedure.
ASKER
works good thanks
ASKER
Very good
Open in new window