Warnings

  • Thread starter Zanetti via AccessMonster.com
  • Start date
Z

Zanetti via AccessMonster.com

I put on table option required (yes) and when on form field wich have this
option is empty access give me msg("you tried to assign Null value to a
variable that is not a data type).It 's not a problem but i want to access
show my message not his message.How can i do that?

Thanks
 
D

Dirk Goldgar

Zanetti via AccessMonster.com said:
I put on table option required (yes) and when on form field wich have
this option is empty access give me msg("you tried to assign Null
value to a variable that is not a data type).It 's not a problem but
i want to access show my message not his message.How can i do that?

There are several ways to do this. I would use code in the form's
BeforeUpdate event to check for the empty field; e.g.:

Private Sub Form_BeforeUpdate(Cancel As Integer)

If IsNull(Me!MyControlName) Then
Cancel = True
MsgBox "You must enter a value for MyControlName."
Me!MyControlName.SetFocus
End If

End Sub

If you want to do it at the table level, not just on the form, you could
use a validation rule instead of the Required property: set the
Required property to No, set te field's Validation Rule to

Is Not Null

and set the Validation Text to your message; for example:

The field MyFieldName must not be left blank.
 

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

Similar Threads


Top