View Full Version : Dlookup type mismatch error


mazza
04-12-2007, 01:42 AM
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???

RoyVidar
04-12-2007, 02:05 AM
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.