Validation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

In VBA or just in form properties:

Where and how do I place a validation rule, so that if the
user has forgotten or missed to select an item from one of
the comboboxes that when they hit the run button it pops
up a reminder to complete the section and has no effect if
they select the cancel button??
 
To validate an individual field use the BeforeUpdate event of the control. If
you want to check one field against another, or that a field has not been left
blank use the BeforeUpdate of the form. In either case you can display your
own user-friendly message box and then use Cancel = True to stop the user from
progressing without attending to the problem.
 
Thank You for your respons.

I still get a little confused with these, even with the
expression builder. I think I should probably use the form
method you mentioned. Each combobox essentially is pulling
data from a table and based on the users selections
determines which queries and macros are run. So I want to
make sure the user selects the fields in the combo box.

I tried placing this in the expression builder for the
BeforeUpdate property of the form but it does not work.

=[CallQ] Is Not Null

CallQ is the combobox name, I will also need to add
something that shows validation text to tell the user to
fill in the blank.

Any thoughts?

Thank You,
 
I would definitely go with the form event rather than the table, even when you
can get the validation that you require at table level the messages are not
exactly kind to users!

For what you are requiring something like this should do you :-

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Nz(CallQ) = "" Then
MsgBox "The whatever a CallQ is must be entered", vbCritical, "Data
missing"
CallQ.SetFocus
Cancel = True
End If
End Sub

Customise the message and add any other requirements similarly. You may or may
not want to use the SetFocus to position the cursor.

--
HTH
John

I still get a little confused with these, even with the
expression builder. I think I should probably use the form
method you mentioned. Each combobox essentially is pulling
data from a table and based on the users selections
determines which queries and macros are run. So I want to
make sure the user selects the fields in the combo box.
I tried placing this in the expression builder for the
BeforeUpdate property of the form but it does not work.
=[CallQ] Is Not Null
CallQ is the combobox name, I will also need to add
something that shows validation text to tell the user to
fill in the blank.
Any thoughts?
-----Original Message-----
To validate an individual field use the BeforeUpdate event of the control. If
you want to check one field against another, or that a field has not been left
blank use the BeforeUpdate of the form. In either case you can display your
own user-friendly message box and then use Cancel = True to stop the user from
progressing without attending to the problem.
the user has forgotten or missed to select an item from one
of the comboboxes that when they hit the run button it popsif they select the cancel button??
 
Back
Top