Making a field required

Lazy Days

Registered User.
Local time
Yesterday, 19:41
Joined
Jun 11, 2008
Messages
10
I have one form where ordering information is entered, but everything can't be entered at the time of order. So I have another form that lets the user finish the information (quantity received and time received) once the product is received, this is usually anywhere from 2 to 6 hours later. I want to make it required to enter a time in the update form if a quantity received is entered. Is there some VB code that will perform this for me?
 
What you can do is set the focus to the time text box after the quantity is filled, then run a check on the time box that it is not null or empty when they try to leave it. This should force the user to enter a time right after they put the order quantity in.
 
I tried the following code but it shows a compile error and highlights the word Received after Quanity. Do I have something wrong? (I know I have Quantity spelled wrong) I was putting this on the Before update on the form.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Quanity Received = "NotNull" AND IsNull(Me.Time Received) = True Then
MsgBox "You must fill in time received before proceeding", , "Fill In Time Received"
Me.Time Received.SetFocus
Cancel = True
End If
End Sub
 
you should not have spaces in your field names make it

quantity_recieved or quantityrecieved

you can even try me.[quantity recieved]
 
I changed the code like you suggested as well as every other place in the database and then put in the following code. It doesn't show any errors but it don't work either and no message box shows up.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Quanity_Received = "NotNull" And IsNull(Me.Time_Received) = True Then
MsgBox "You must fill in time received before proceeding", , "Fill In Time Received"
Me.Time_Received.SetFocus
Cancel = True
End If
End Sub
 
do not put "not null" in quotes

it would be
if isnotnull(me.quantity_recieved) and isnull(me.time_recieved) then
 

Users who are viewing this thread

Back
Top Bottom