Own Msgbox BEFORE access's MsgBox

  • Thread starter faapa via AccessMonster.com
  • Start date
F

faapa via AccessMonster.com

Hi there

I was wondering if someone can tell me how to switch off an error msg i am
getting on a form. I've set out a validation error so my own msgbox appears
however access's msgbox seems to beat me to it! Can anyone help?
 
F

faapa via AccessMonster.com

Sorry - forgot to mention

the error msg i am currently getting is -

"The field 'tbl_employee_key.PK_PE_ID' cannot contain Null value becasue the
required property for this field is set to true. Please enter a value in this
field"

I understan that the field is required entry but i'd like the user to be able
to complete the data in the other boxes before entering data pk_pe_id but the
access msgbox comes up as soon as data in entered in another (non required)
box
 
A

Allen Browne

Strange. You should not get that message unless you start entering something
in the field, and backspace it out. To solve that case, press the Esc key
once to undo the field.

Once you have started entering into a required field, the data engine will
apply the rule before any of your code fires, so you can't avoid the message
with code. (You can capture the message in Form_Error, but not avoid it.)

There is another problem that arises If all these conditions are true:
- the form is based on a query that uses more than one table, and
- you get the message on the very first keystroke when you start adding a
new record, and
- you get the message even if you are not entering into this box.
In that case, the issue is that there is a Default Value set in one of the
fields from the table you are not adding records to, but Access is confused
and trying to assign the default to that field anyway. To solve the problem,
remove the Default Value from all fields in the other table (as well as from
any text boxes on your form that are bound to fields in the other table.)

A wild alternative is to set the Required property of your field to no, and
instead set the Validation Rule for the *table* to:
[pk_pe_id] Is Not Null
The Validation Rule for the table is in the Properties box in table design.
By using the rule for the table, you have record-level validation instead of
field-level validation, which delays it until Access attempts to save the
record.
 

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