Results 1 to 2 of 2

Thread: Syntax

  1. #1
    5 Star Lounger
    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 & "'")

    End Function

    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?


  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Sacramento, California, USA
    Thanked 1 Time in 1 Post

    Re: Syntax

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts