Validation rule problem

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
 
G

Geo

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
 
J

John Vinson

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top