Dlookup type mismatch error

mazza

Registered User.
Local time
Today, 09:50
Joined
Feb 9, 2005
Messages
101
If have trouble with my Dlook upcode and I am stuck

Invoicelabour = Yes/No field
ContractNr = Text field
ServicecontractNr = text field

When I run an after update event I get the runtype error type mismatch on the chargelabour = … line




Dim Chargelabour As Boolean

Chargelabour = DLookup("[InvoiceLabor]", "[TblContract]", "[TblContract].[ContractNr] =" & Forms![FrmServiceJobDetails]![servicecontractNr])

If Chargelabour = True Then Invoice.Value = True


Any idea???
 
Since the field involved in your criterion is text, it will need text delimiters (single quotes)

Chargelabour = DLookup("[InvoiceLabor]", "[TblContract]", "[ContractNr] ='" & Forms![FrmServiceJobDetails]![servicecontractNr] & "'")

If servicecontractNr is on the current form (where you run this code), you can use

Me!servicecontractNr

in stead of the fully qualified reference. Also, since you only have one field called ContractNr in the table, there's no need for table prefix.
 

Users who are viewing this thread

Back
Top Bottom