Solved Dlookup....Another one ;) (1 Viewer)

TajikBoy

Member
Local time
Today, 07:02
Joined
Mar 4, 2011
Messages
82
Hi guys,

Me again,

Trying to Dlookup a numeric value with 2 text criteria

Me.BillingRate = DLookup("Rate", "tblBillingRates", "Category = '" & Me.Category & "'" And "Position = '" & Me.Position & "'")

With above I get type Mismatch Error 13 and for love or god, can't understand why.... tblbillingrates snapshot is below, BillingRate is a field on my form alongside category and position

Any ideas?

table.png
 

plog

Banishment Pending
Local time
Today, 09:02
Joined
May 11, 2011
Messages
11,638
...& "'" And "Position = '" & ...

Your AND exists outside of double quotes but you don't use & before nor after it. You've overquoted.
 

cheekybuddha

AWF VIP
Local time
Today, 15:02
Joined
Jul 21, 2014
Messages
2,272
You'll kick yourself when you work it out!

Me.BillingRate = DLookup("Rate", "tblBillingRates", "Category = '" & Me.Category & "' And Position = '" & Me.Position & "'")
 

cheekybuddha

AWF VIP
Local time
Today, 15:02
Joined
Jul 21, 2014
Messages
2,272
A good trick is to use a variable to build your criteria which you can output to the Immediate Window (Ctrl+G) to check if needed:
Code:
Dim strCriteria As String

strCriteria = "Category = '" & Me.Category & "' And Position = '" & Me.Position & "'"
Debug.Print strCriteria
Me.BillingRate = DLookup("Rate", "tblBillingRates", strCriteria)
 

TajikBoy

Member
Local time
Today, 07:02
Joined
Mar 4, 2011
Messages
82
You'll kick yourself when you work it out!

Me.BillingRate = DLookup("Rate", "tblBillingRates", "Category = '" & Me.Category & "' And Position = '" & Me.Position & "'")

Well, instead of kicking, I banged my head on the keyboard..... same same.....

Thank you CheekyBuddha
 

Users who are viewing this thread

Top Bottom