Results 1 to 2 of 2
2001-01-26, 00:35 #1
- Join Date
- Jan 2001
- Newbury, Berkshire, England
- Thanked 0 Times in 0 Posts
I spent day's trying to get the "Dlookup" function to work properly in this function.
Private Function Fct_Mup() As Currency
Dim X1 As String
Dim Y1 As String
Dim z1 As String
X1 = Cbo_LorrySize.Value
Y1 = Cbo_Discount.Value
z1 = Cbo_MatlMup.Value
Fct_Mup = DLookup(X1, Y1, "[matlcode] = '" & z1 & "'")
It works OK now, the key is in the syntax of the last argument,
'" & z1 & "'"
Can anyone explain to me why it needs all these apostrophes and ampersands to work? And where is the help info on this?
2001-01-26, 03:48 #2
- Join Date
- Dec 2000
- Sacramento, California, USA
- Thanked 1 Time in 1 Post
The syntax for DLookup includes 3 arguments: 1) the field name or expression you're looking up as a string, 2) the name of the domain (a table or query) in which you want to search, and 3) a where clause specifying the criteria for the search.
You're passing it:
1) whatever value is in your Cbo_LorrySize control as the lookup argument,
2) whatever value is in your Cbo_Discount control as the domain name argument, and
3) a criteria expression that compares the contents of the [matlcode] field to a string containing the value in your Cbo_MatlMup control.
You need the amperands and single quotes to make it realize the the value in Cbo_MatlMup has to be evaluated as a string and not a literal value.Charlotte