Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Validation IsNull()...

Status
Not open for further replies.

wreded

Technical User
Dec 18, 2001
119
US
i've been messing with this for a couple of weeks and can't seem to get it right.
Scenario: Form to get user data. Some information is collected and stored, some data is output to a (15 page!) form and the information is thrown away and not stored. The form is a Word document and i can get all the output in correctly with the exception of one field i call [Suffix] for 'Jr., Sr., III', etc. i ALWAYS get Error 94, Invalid use of Null when the field is blank, but when it has info in it it outputs correctly. i've tried all the permutations i can think of to check for Null, but it has never worked yet.
Code:
 'txtSuffix = IIf(IsNull(CStr(Forms!form1!Suffix)), "", (CStr(Forms!form1!Suffix)))
 If IsNull(CStr(Forms!form1!Suffix)) Then
    txtSuffix = ""
 Else
    txtSuffix = CStr(Forms!form1!Suffix)
 End If
How in the heck do i check for Null if i can't check for Null?
Thanks,
Dave
 
Does this not work?

If IsNull(Forms!form1!Suffix) Then

You may wish to use:

If Trim(Forms!form1!Suffix & "")="" Then

This will check for space filled, empty and null.

 
Thanks! The first one worked! i'll try the second one too. Why doesn't it work with CSTR()?
Dave
 
Because you cannot coerce a null to a string.
 
i just had that thought too. DUH me!
Thanks!
 

Now that you've given yourself a dope slap (hope it didn't hurt too much!) why were you trying to coerce what obviously has to be a string (Suffix) into being a string?

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Here's the long and short of it. To admit individuals to the network we have to fill out a 15 page form. i've created one in .PDF that autofills some of the information but that information doesn't get in to our database. Some of the information requested we don't keep, some we do. i'm trying to get an MS Word form (fed from the required information) to fill the database and fill the form at the same time. i'm obviously doing lots of things wrong, but i'm doing some things right as i'm getting some of the information on a dummy form. i'm having trouble with checkboxes right now; 4 groups refuse to transfer their information to the MS Word form. i'm probably trying to change them to text information as opposed to Boolean or something like that.
Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top