Quick and probably quite simple Invalid Use of Null Aftermath Ques

  • Thread starter Thread starter Tal
  • Start date Start date
T

Tal

Hi all and thanks in advance for all your help.

So, I had a invalid use of Null error happening with a stack of DLookups,
which I solved with the Nz function, as exampled below:

dlookClientFirstName = Nz(DLookup("[txtClientFirstName]", "tblClients",
"[keyClient] = " & Me.Parent!keyClient), "")
dlookClientLastName = Nz(DLookup("[txtClientLastName]", "tblClients",
"[keyClient] = " & Me.Parent!keyClient), "")


However, now my whole RowSource blurb doesn't work properly because it was
dependent on the Nulls, as exampled below (don't worry that there are more
fields referenced here than I included above:

If IsNull(dlookClientLastName) = False Then
strReceiptTo = strReceiptTo & dlookClientFirstName & " " &
dlookClientLastName & ";"
End If
If IsNull(dlookCompanyOnly) = False Then
strReceiptTo = strReceiptTo & dlookCompanyOnly & ";"
End If
If IsNull(dlookSpouseFirstName) = False Then
strReceiptTo = strReceiptTo & dlookSpouseFirstName & " " &
dlookClientLastName & ";"
strReceiptTo = strReceiptTo & dlookClientFirstName & " or " &
dlookSpouseFirstName & " " & dlookClientLastName & ";"
End If

So now I am left with all kinds of empty and partial rows in my dropdown.
So, how do I rewrite the If... statement to reflect the new value of ""
instead of Null.

Again, thanks in advance.

Tal
 
Tal

the if IsNull(dlookclientlastname) will never work, because they will never
be nulls it always be false (because you used NZ the nulls will be converted
to empty strings "" )

use instead If dlookClientLastName <>"" then

Tom
 
Hi Chegu Tom,

That was exactly what I needed. Thank you!!

Cheers,
Tal

Chegu Tom said:
Tal

the if IsNull(dlookclientlastname) will never work, because they will never
be nulls it always be false (because you used NZ the nulls will be converted
to empty strings "" )

use instead If dlookClientLastName <>"" then

Tom

Tal said:
Hi all and thanks in advance for all your help.

So, I had a invalid use of Null error happening with a stack of DLookups,
which I solved with the Nz function, as exampled below:

dlookClientFirstName = Nz(DLookup("[txtClientFirstName]", "tblClients",
"[keyClient] = " & Me.Parent!keyClient), "")
dlookClientLastName = Nz(DLookup("[txtClientLastName]", "tblClients",
"[keyClient] = " & Me.Parent!keyClient), "")


However, now my whole RowSource blurb doesn't work properly because it was
dependent on the Nulls, as exampled below (don't worry that there are more
fields referenced here than I included above:

If IsNull(dlookClientLastName) = False Then
strReceiptTo = strReceiptTo & dlookClientFirstName & " " &
dlookClientLastName & ";"
End If
If IsNull(dlookCompanyOnly) = False Then
strReceiptTo = strReceiptTo & dlookCompanyOnly & ";"
End If
If IsNull(dlookSpouseFirstName) = False Then
strReceiptTo = strReceiptTo & dlookSpouseFirstName & " " &
dlookClientLastName & ";"
strReceiptTo = strReceiptTo & dlookClientFirstName & " or " &
dlookSpouseFirstName & " " & dlookClientLastName & ";"
End If

So now I am left with all kinds of empty and partial rows in my dropdown.
So, how do I rewrite the If... statement to reflect the new value of ""
instead of Null.

Again, thanks in advance.

Tal
 
Back
Top