validation of null

A

angie

I am writing a small database which is going to be used by
users who are not computer literate and have low
intellect. There are fields in the database which must be
filled in and I am trying to validate using message boxes
stating exactly which field is empty rather than the user
just getting the error message 'Invalid Use of Null'

I have been trying to look at the length of the field ie
is it empty but it keeps overlooking this for 'Invalid
Use of Null'

I have set all the fields to say in the table that these
are not required so that the error messages don't keep
coming up and I can put them in myself but i can't quite
get the syntax right.

what syntax can i use which will just check if it is null
and let me continue


Any suggestions really appreciated
 
M

Michel Walsh

Hi,


You probably try to assign the Value of the field, its default property,
a VARIANT, into a STRING data type.


Dim myStr As String

myStr = Me.ControlName



YOU CAN'T store a NULL into a string. Either use a variant for your
internal storage (we generally don't have to, use the control instead),
either test it before:


Dim myStr As String

If IsNull(Me.ControlName ) Then
... ??? ...
Else
myStr = Me.ControlName

End If



You can test for the values in the AfterUpdate event of each control,
and also trap error in the onError event of the Form (which allow you to
change the text of the error message if an error is reported there,
generally when we try to save the whole record on the hard disk, not
individual controls).




Hoping it may help,
Vanderghast, Access MVP
 

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