Validation rule problem

  • Thread starter Thread starter Geo
  • Start date Start date
G

Geo

I am introducing data in a table using a form with combo boxes and
textboxes, with values selected from a query and from some tables.
Begining with cbobox2, for every combo box I can have a diferent graoup of
posible values for every value of the precedent combo box, so I used for the
"On change" property of every combo box "Me.Refresh".
On the other hand, I used for every field of the table the VALIDATION RULE
"Is not Null", for preventing the users letting them blank, with no data.
The problem is that when I introduce data in the blank cboBox1, follows the
refresh, and is automatically executed the validation rule, and I get the
message "Runtime error '3316': MY_VALIDATION_TEXT"
How can I solve thies problem? (preventing the blank fields without
interfering with the refresh (wich is absolutelly necessary)?

Thank you
 
Thank you, both, but it seems I'm not that good.Can you help me one more
time telling me (eventualy with an example) HOW CAN I SET THE FOLLOWING
COMBO BOXES TO NULL?
Thank you again!
Geo
 
I am introducing data in a table using a form with combo boxes and
textboxes, with values selected from a query and from some tables.
Begining with cbobox2, for every combo box I can have a diferent graoup of
posible values for every value of the precedent combo box, so I used for the
"On change" property of every combo box "Me.Refresh".

The BeforeUpdate event is probably better. The "Change" event fires
*at every keystroke*, and does not fire when you select a record from
the combo.
On the other hand, I used for every field of the table the VALIDATION RULE
"Is not Null", for preventing the users letting them blank, with no data.
The problem is that when I introduce data in the blank cboBox1, follows the
refresh, and is automatically executed the validation rule, and I get the
message "Runtime error '3316': MY_VALIDATION_TEXT"
How can I solve thies problem? (preventing the blank fields without
interfering with the refresh (wich is absolutelly necessary)?

As suggested, it is NOT necessary to Refresh, nor is it necessary to
set the combo boxes to NULL.

Try putting code like this in the Form's (not the combo box's)
BeforeUpdate event:

Private Sub Form_BeforeUpdate(Cancel as Integer)
If IsNull(Me!combobox1) Then
Cancel = True
MsgBox "Please fill in combobox1", vbOKOnly
Me!combobox1.SetFocus
Elseif IsNull(Me!combobox2) Then
<etc etc>


John W. Vinson[MVP]
(no longer chatting for now)
 
On a form, field controls of several fields have the Validation Rule set to
"is Not Null" . The fields in the underlying table do allow null. The form
validation rules do not appear to be working as the form is allowing those
fields to be tabbed through without any error message popping up.

Has anybody run across this before?

Thanks

Trish
 
Back
Top