Updating a text field from a combo box of another field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nocus
    New Member
    • Apr 2010
    • 1

    #1

    Updating a text field from a combo box of another field

    Private Sub FundDescription _AfterUpdate()

    ' Evaluate filter before it is passed to DLookup function.
    strFilter = "FundDescriptio n = " & Me!FundDescript ion

    ' Look up product's unit price and assign it to the UnitPrice control.
    Me!FundCode = DLookup("FundCo de", "tbl_Fund", strFilter)

    End Sub

    error is: data type mismatch in criteria expresion
  • MikeTheBike
    Recognized Expert Contributor
    • Jun 2007
    • 640

    #2
    Originally posted by nocus
    Private Sub FundDescription _AfterUpdate()

    ' Evaluate filter before it is passed to DLookup function.
    strFilter = "FundDescriptio n = " & Me!FundDescript ion

    ' Look up product's unit price and assign it to the UnitPrice control.
    Me!FundCode = DLookup("FundCo de", "tbl_Fund", strFilter)

    End Sub

    error is: data type mismatch in criteria expresion
    Hi

    I think this
    strFilter = "FundDescriptio n = " & Me!FundDescript ion
    should be this
    strFilter = "FundDescriptio n = '" & Me!FundDescript ion & "'"

    You need to enclose the text/string field/varable inside apostrophies so the compiler knows where the valiable starts and end within the total string expression!!?

    HTH

    MTB

    Comment

    Working...