Solved

# DSum with multiple criteria

Posted on 2011-10-14
246 Views
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")
0
Question by:SteveL13

LVL 33

Expert Comment

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")

jppinto
0

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'")
0

Author Comment

Note:  JobN and PartN and Type are text fields.
0

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'")
0

LVL 119

Expert Comment

use the second Dsum i posted above
0

## Featured Post

### Suggested Solutions

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.