Dlookup syntax

Posted on 2012-08-12
Last Modified: 2012-08-12
Can someone tell me what is wrong with this onprint event code?

Me.txtCustName = DLookup("[CompanyName]", "tblCustomers", "[CustNum] = Me.txtCustNum)
Question by:SteveL13
    LVL 61

    Accepted Solution

    Change the criteria to

    "Custnum =" & me.custnum
    LVL 56

    Expert Comment

    by:Jim Dettman (Microsoft MVP/ EE MVE)
    If CustNum is a text field, your going to need:

     "Custnum = " & chr$(34) & me.custnum & chr$(34)

     The Chr$(34) gives you the quote character, so you end up with:

     Custnumb = "<some value>"

     Would be worth it to read:

     which discusses passing strings within a string.


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    This isn't a frequent question on EE. I must have seen it three or four times (among several thousand questions). However, I use this trick quite often, most frequently as a delayed Current event. A form does not expose it's calculation dependenc…
    I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
    In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
    In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now