GetAddress() not working!

  • Thread starter Thread starter Gina Whipp
  • Start date Start date
G

Gina Whipp

Hi All,

Decided to report, Fred answered my last question...

I abbreviated the code for this eMail... It's not working, no message just
nada, zilch, zero, okay you get the idea. What's wrong this time, probably
my fault. My object is to look up address based on the entry from another
field.

Function GetAddress(Tos As Long)

Dim CA As String

CA = DLookup("Client", "qryClientNames", "cpClientID =" & 1)

If Tos = 1 Then
GetAddress = CA
Else
GetAddress = "No Address"
End If

End Function
 
Hi Gina,

The fact that the response is not "No Address" would point to you not having
a record of a Client in qryClientNames with a ClientID of 1, and CA is
replied with Null as it's response. Presumably if you use GetAddress(2) you
get the reply " No Address" ?

TonyT..
 
Tony,

Not the case, I have only one sample client entered and it is 1. I tried 0
and 2 and got error messages invalid use of null, I expected that.
 
It's not working, no message
just nada, zilch, zero, okay you get the idea.
Function GetAddress(Tos As Long)

It can't return a Null; if the DLookup() returned a null because there is
no record where cpClientID=1, then the line would fail with an Invalid
Use of Null.

It might be returning "", in which case it must be the value of Client in
the appropriate record.

Perhaps this might be more like what you want:

Function GetAddress(Tos As Long) as string
Dim temp as Variant
temp = DLookup("Client", "qryClientNames", _
"cpClient = " & Format(tos, "0))

if isnull(temp) Then
getaddress = "No such record"
else
getaddress = CStr(temp)
end if

end function


Hope that helps


Tim F
 
Hi again,

Have you tried GetAddress(2) or
CA = DLookup("Client", "qryClientNames", "cpClientID =" & 1)

I would have expected;

CA = DLookup("Client", "qryClientNames", "cpClientID = " & Tos & "")

But this of course would generate errors for any value but 1 in your test
environment.

Have you put a stop in your code at the beginning of this function to follow
it through?

TonyT..
 
Tony,

I need more coffee... operator error, I forgot the question mark...
?GetAddress(1)

Thanks for replying,
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II
 

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

Back
Top