Making a field required before other fields

vX987

Registered User.
Local time
Today, 06:14
Joined
Jun 29, 2007
Messages
51
Is there anyway to make a field on a form required BEFORE any data can be entered into the other fields? I've been having a pop-up message as a reminder, but that gets really annoying because it pops up EVERYTIME I open the form.

Ex. I have a database based on Patients, Patient Visit Date, and Patient exam results. If I DON'T enter in the Visit Date first and start entering data into the exam result subforms first, the data DOES NOT relate to the patient.

However, if I enter in the Visit Date FIRST, then it DOES relate to the patient. Kinda weird, I have no idea where the missed relationship is, but I just thought that maybe if I made the Patient Visit Date required first then that would be ok for now.

Help anyone?

This is the advice I received,
Set the [Patient Visit Date] control to required and set the focus to it in the Current event procedure of the form.
What does this mean?

vX987 ------> Access Newbie
 
You could use the Before_Update event of your controls and cancel the update if the required field is Null.
 
The advice you were given means in the OnCurrent event of your form set the focus to your required date control and then in the exit event of that control check and see if the control has been completed and Cancel = True if the user has not entered a date yet. Cancel = True will hold the focus in that control. There are actually several ways to skin this cat as you might expect. You could also disable all of the other controls until the date is set properly.
 
Ok, you might get a little frustrated with me asking this, but I still don't get it. So what do it put in here?:

Private Sub Form_Current()

End Sub

and what here?:

Private Sub VisitDateMain_Exit(Cancel As Integer)

End Sub


So this works if Visit Date is the first thing I must enter in right? Because if I already entered in some data AND THEN go.. "ooops I forgot the Visit Date" and then go enter the Visit Date, the data I just entered in will still be there, BUT does not relate to the patient anymore.

I like the idea of, "You could also disable all of the other controls until the date is set properly," that RuralGuy suggested.

How would I do that?

Thank you so much!
 
Code:
Private Sub Form_Current()

Me.VisitDateMain.SetFocus

End Sub

Private Sub VisitDateMain_Exit(Cancel As Integer)

If Not IsDate(Me.VisitDateMain) Then
   MsgBox "Please enter a valid date"
   Cancel = True
End If

End Sub
 
Thank you RuralGuy, works like a charm! :)
 

Users who are viewing this thread

Back
Top Bottom