Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using string passed to function in DLookup criteria

Status
Not open for further replies.

cswosu

Technical User
Apr 16, 2004
12
0
0
US
I can't get DLookup to use the RateCode string that was passed into the function in its criteria. The RateCode is a letter that corresponds to a certain rate schedule in RateTable. It is ignoring it for some reason. What am I doing wrong?

******

Public Function getCustomerSpecificMileage(RateCode As String, Miles As Integer) As Currency
'This function gets the Mileage Rate from the Rate table
'and the Miles is passed into it, it then calculates the Mileage and
'returns the Mileage value in dollars
Dim Rate As Currency
Rate = DLookup("[NRate]", "RateTable", "[RateCode] = RateCode And [Title] = 'MileageRate'")
getCustomerSpecificMileage = Rate * Miles
End Function

******

Thanks,
Craig
 
If RateCode is text not an integer you will need to use it like this:

"[RateCode]=" & "'" & RateCode & "'"

Frank J Hill
FHS Services Ltd.
frank@fhsservices.co.uk
 
Thank you, sir. That is just what I needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top