DSum with multiple criteria

Posted on 2011-10-14
Last Modified: 2012-05-12
On the after update event of a combox box I want a field to populate with a number from the following code.  But something is wrong with it.  Can anyone help?  Here it is...

Me.txtQtyFGtoDate = DSum("[Qty]", "tblTransactions", "[JobN] = me.txtJobN" And "[PartN] = me.partN" And [Type] = "FG")
Question by:SteveL13
    LVL 33

    Expert Comment

    Instead of this:

    Me.txtQtyFGtoDate = DSum("[Qty]", "tblTransactions", "[JobN] = me.txtJobN" And "[PartN] = me.partN" And [Type] = "FG")

    Try like this:

    Me.txtQtyFGtoDate = DSum("[Qty]", "tblTransactions", "[JobN] = me.txtJobN" And "[PartN] = me.partN" And "[Type] = FG")

    LVL 119

    Accepted Solution


    if  JobN is Number and PArtN is number

    Me.txtQtyFGtoDate = DSum("[Qty]", "tblTransactions", "[JobN] =" & me.txtJobN & " And [PartN] = " & me.partN & " And [Type] = 'FG'")

    if they are text datatype

    use this

    Me.txtQtyFGtoDate = DSum("[Qty]", "tblTransactions", "[JobN] ='" & me.txtJobN & "' And [PartN] = '" & me.partN & "' And [Type] = 'FG'")

    Author Comment

    Note:  JobN and PartN and Type are text fields.
    LVL 33

    Expert Comment

    If you are trying to include values from the form.

    Me.txtQtyFGtoDate = DSum("[Qty]", "tblTransactions", "[JobN] =" & Me.txtJobN & " And [PartN] = " & Me.partN & " And [Type] = 'FG'")
    LVL 119

    Expert Comment

    by:Rey Obrero
    use the second Dsum i posted above

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
    In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

    761 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

    12 Experts available now in Live!

    Get 1:1 Help Now