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

dlookup

Status
Not open for further replies.

mikeba1

Programmer
Jan 2, 2005
235
GB
I am pulling my hair out !!
The following code gives error 2001 cancelled previous operation

'MsgBox ("email therapist booking")
Dim therem
therem = DLookup("[E-mail]", "[therapists]", "therapist= " & Forms![zoom]!ther)
If therem > "" Then
' Call emailaddtherapist(therem, noteb, notea)
End If

e-mail is a field on the table therapists with the key of therapist
form zoom field ther contains a valid therapist id

Help
 
If by chance therapist isn't a numeric field:
Code:
therem = DLookup("[E-mail]", "[therapists]", "therapist=[!]'[/!]" & Forms![zoom]!ther [!]& "'"[/!])

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Sometimes you can't see the woods for the trees.

Thanks PHV, works fine
 
In your code you currently have the line

Code:
[b]Call emailaddtherapist(therem, noteb, notea)[/b]

commented out, but if you intend to use it later, you need to be aware that when no match is found using the criteria with DLookup() it does not return a Zero-Length String, which is what you are testing for with this:

Code:
[b]If therem > "" Then
' Call emailaddtherapist(therem, noteb, notea)
End If[/b]

Instead, it returns a Null, so use this:

Code:
[b]If Not IsNull(therem) Then
' Call emailaddtherapist(therem, noteb, notea)
End If[/b]


The Missinglinq

Richmond, Virginia

The Devil's in the Details!
 
Thanks
It was only commented out whilst testing.
 
That's what I figured!

The Missinglinq

Richmond, Virginia

The Devil's in the Details!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top