Type mismatch

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all

I am trying to use the dlookup function and get a type mismatch error. Can
anyone tell me why. The fields in the tables are either double or text
(bracket). Code is:

Dim txtBracket As String
Dim intFuelAmt As Double
Dim intVAT As Double

txtBracket = Me![cboVehicle].Column(3)
intFuelAmt = Me![FuelCost]
intVAT = DLookup("[Amount]", "tblFuel", "FuelCost = " & intFuelAmt
And "Bracket = " & txtBracket)

Thanks in advance for any help.
Sue
 
hi,
text should be in quotes, and you have to be aware of null, so try:

intVAT = nz(DLookup("[Amount]", "tblFuel", "FuelCost = " & intFuelAmt & "
And Bracket = '" & txtBracket"'"),0)
 
Great thanks Alex that sorted it (although you had a missing & before the "'"
after txtbracket.

Cheers
Sue

Alex Dybenko said:
hi,
text should be in quotes, and you have to be aware of null, so try:

intVAT = nz(DLookup("[Amount]", "tblFuel", "FuelCost = " & intFuelAmt & "
And Bracket = '" & txtBracket"'"),0)


--
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


hughess7 said:
Hi all

I am trying to use the dlookup function and get a type mismatch error. Can
anyone tell me why. The fields in the tables are either double or text
(bracket). Code is:

Dim txtBracket As String
Dim intFuelAmt As Double
Dim intVAT As Double

txtBracket = Me![cboVehicle].Column(3)
intFuelAmt = Me![FuelCost]
intVAT = DLookup("[Amount]", "tblFuel", "FuelCost = " & intFuelAmt
And "Bracket = " & txtBracket)

Thanks in advance for any help.
Sue
 
Back
Top