Cancelled previous operation error

Malcy

Registered User.
Local time
Today, 21:19
Joined
Mar 25, 2003
Messages
584
Hi
I am trying to use DLookup to identify current record details and I am using
Code:
    varRegister = DLookup("[lngTsin]", "dbo_tsin", "[strEmp] = " & Me.cboStaff & " And [lngWeek] = '" & Me.cboWeekNo & "'")
I keep getting a "You have cancelled previous operation" error. I have narrowed it down to this line.
Initially I didn't have the '" and "'" around the last parameter but checking through other issues like this some seemed to have it.
When I debug and hover over the line both cboWeekNo and cboStaff are showing the correct numeric values.
Any help would be most appreciated.
Thanks
 
Looks like you wrapped the wrong field by the look of it. You wrap text field but not numbers

varRegister = DLookup("[lngTsin]", "dbo_tsin", "[strEmp] = '" & Me.cboStaff & "' And [lngWeek] = " & Me.cboWeekNo )

Peter
 
That did the trick Peter
Thanks very much
I will try hard to remember but find these bits fall out of my memory much quicker than they go in!
Best wishes
 
I have got the same error as above, but wrapping text doesn't fix it. What could be wrong?

Code:
If IsNull(DLookup("[lastname]", "[advocacy]", "[lastname]=" & Me.LastName)) Then
Me.Refresh
DoCmd.OpenForm "advocacy", , , , acFormAdd, , Me.LastName
Let Forms![Advocacy]!ClientID.DefaultValue = Me.ClientID
Else
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit, , Me.LastName
End If
 
The text should be wrapped
If IsNull(DLookup("[lastname]", "[advocacy]", "[lastname]='" & Me.LastName &"'")) Then

If that does not cure it then try stepping through your code to see just where the code is failing.

Peter
 
That was the problem.

Thanks so much!

Just so I get the hang of wrapping-

the fieldname should be "[]", but I'm not sure why the critera should be "&... & "'"?
 
When you use text for the criteria you have to wrap it in quotes,
"[lastname]='" & Me.LastName &"'"

if the criteria is numeric you don't need to wrap it in quotes so
"[ID]=" & Me.ID

Hope that is clearer

Peter
 

Users who are viewing this thread

Back
Top Bottom