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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

invalid use of Null - continued

Status
Not open for further replies.

rlusk49

Technical User
Nov 7, 2002
18
CA
Sorry you guys who offered help on getting "invalid use of Null" message. Still having trouble. Here is the code. In the DB, "AllowZeroLength = YES". As I mentioned, works fine when there is data in the fields.

arrSpouseParents = mobjSpouseParents.GetSpouseParents(mlngPersonID)

If Not IsEmpty(arrSpouseParents) Then

txtMGFather.Text = arrSpouseParents(0, 0)
txtMGMother.Text = arrSpouseParents(1, 0)

Else

txtMGFather.Text = ""
txtMGMother.Text = ""

End If
 
Does it hang on the line where it computes the IF? ... or does it hang once it's reached the else's first line of code?
 
It hangs on:

txtMGFather.Text = arrSpouseParents(0, 0)

run-time error '94'

Invalid use of Null
 

Well, the way I see it, it is the way that you are trying to evaluate the array. If arrSpouseParents(0,0) is null and arrSpouseParents(1,0) is not null then your evaluation will return not null, but because you then do txtMGFather.Text = arrSpouseParents(0,0) you recieve the null error. You will find this out by testing the following code.

[tt]
Option Explicit

Private Sub Form_Load()

Dim MyArray(1, 1)
MyArray(0, 0) = "test"
MyArray(0, 1) = Null
MyArray(1, 0) = Null
MyArray(1, 1) = Null

If IsNull(MyArray) = True Then Exit Sub

Text1.Text = MyArray(0, 0)
Text1.Text = MyArray(0, 1)
Text1.Text = MyArray(1, 0)
Text1.Text = MyArray(1, 1)

End Sub
[/tt]

So to correct this in your code you are going to have to break out your evaluations to test for each member/element of the array. You could do it like so...

[tt]
txtMGFather.Text = IIf(IsNull(arrSpouseParents(0, 0) = True, "", arrSpouseParents(0, 0)
txtMGMother.Text = IIf(IsNull(arrSpouseParents(1, 0) = True, "", arrSpouseParents(1, 0)
[/tt]

Or you could use your basic If...Then...Else statement like you have above.

I Hope This Helps, Good Luck

 
try this

txtMGFather.Text = arrSpouseParents(0, 0) & ""

All the best Praveen Menon
pcmin@rediffmail.com
 
This works:

txtMGFather.Text = arrSpouseParents(0, 0) & ""

Thanks a million.
 
You know you can show courtesy by voting?

All the best Praveen Menon
pcmin@rediffmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top