Not Null not working

  • Thread starter DJ Notion via AccessMonster.com
  • Start date
D

DJ Notion via AccessMonster.com

Hello.

I have a form called Login containing a combo box and a text box linked back
to two fields in a table. I have a validation rule for each not to be null.
I also have the two fields in the table being required. On my Login form I
have a button that opens another form. The problem is when I first open the
Login form and click OK, it will open the other form even if the combo box
and text box are empty.

Any help is appreciated. Thanks.
 
D

DJ Notion via AccessMonster.com

The validation rule I have for the combo box is:

Is Not Null And "C" Or "Ch" Or "D" Or "I" Or "L" Or "Pa" Or "Pr" Or "Sh" Or
"Si" Or "Su" Or "T"

The validation rule I have for the text box is:

Is Not Null And "s96" Or "s06" Or "c99" Or "b03" Or "w87" Or "s86" Or "s91"
Or "s01" Or "v99" Or "t88" Or "z95"

When first opening the form and leaving both the combo box and text box blank
and clicking the command button, it opens the next form even though both have
nothing in them.
What's the actual code you're using?
[quoted text clipped - 10 lines]
Any help is appreciated. Thanks.
 
D

Douglas J. Steele

I'd do the checking in the code for the Click event of the button that opens
the form, rather than using validation rules.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


DJ Notion via AccessMonster.com said:
The validation rule I have for the combo box is:

Is Not Null And "C" Or "Ch" Or "D" Or "I" Or "L" Or "Pa" Or "Pr" Or "Sh"
Or
"Si" Or "Su" Or "T"

The validation rule I have for the text box is:

Is Not Null And "s96" Or "s06" Or "c99" Or "b03" Or "w87" Or "s86" Or
"s91"
Or "s01" Or "v99" Or "t88" Or "z95"

When first opening the form and leaving both the combo box and text box
blank
and clicking the command button, it opens the next form even though both
have
nothing in them.
What's the actual code you're using?
[quoted text clipped - 10 lines]
Any help is appreciated. Thanks.
 
D

Dirk Goldgar

In
DJ Notion via AccessMonster.com said:
The validation rule I have for the combo box is:

Is Not Null And "C" Or "Ch" Or "D" Or "I" Or "L" Or "Pa" Or "Pr" Or
"Sh" Or "Si" Or "Su" Or "T"

The validation rule I have for the text box is:

Is Not Null And "s96" Or "s06" Or "c99" Or "b03" Or "w87" Or "s86" Or
"s91" Or "s01" Or "v99" Or "t88" Or "z95"

When first opening the form and leaving both the combo box and text
box blank and clicking the command button, it opens the next form
even though both have nothing in them.

Validation rules specified for fields or controls only apply when the
data in the field is changed. If the field is never touched, the rule
is not evaluated. If the controls are bound to fields in a table, the
Required property (set for the table fields) will work to keep the
fields being stored as Null. However, that won't be evaluated until
Access attempts to save the record. From the sound of it, the record on
your form is not being modified at all, so there's nothing to make
Access attempt to save it.

Doug's suggestion, checking in the Click event of the button, should
take care of the problem. Or you could make the button be initially
disabled, and only enable it in the AfterUpdate events of the other
controls on the form.
 
D

DJ Notion via AccessMonster.com

Thanks for the feedback. Got it fixed.

Dirk said:
The validation rule I have for the combo box is:
[quoted text clipped - 9 lines]
box blank and clicking the command button, it opens the next form
even though both have nothing in them.

Validation rules specified for fields or controls only apply when the
data in the field is changed. If the field is never touched, the rule
is not evaluated. If the controls are bound to fields in a table, the
Required property (set for the table fields) will work to keep the
fields being stored as Null. However, that won't be evaluated until
Access attempts to save the record. From the sound of it, the record on
your form is not being modified at all, so there's nothing to make
Access attempt to save it.

Doug's suggestion, checking in the Click event of the button, should
take care of the problem. Or you could make the button be initially
disabled, and only enable it in the AfterUpdate events of the other
controls on the form.
 

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