Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to code sum if (...) in access same like sumif(......) in exce

1 view
Skip to first unread message

hisham

unread,
Nov 18, 2007, 7:20:00 PM11/18/07
to
i want to sum if data in table in access database. means same item must be
calculate sum.
sum if like sum if in excel. how to write code?
any body can help me?

Marshall Barton

unread,
Nov 18, 2007, 10:47:35 PM11/18/07
to
hisham wrote:

>i want to sum if data in table in access database. means same item must be
>calculate sum.
>sum if like sum if in excel. how to write code?


Try this kind of expression:
Sum(IIf(condition, item, 0))

--
Marsh
MVP [MS Access]

hisham

unread,
Nov 19, 2007, 4:04:02 AM11/19/07
to

"Marshall Barton" wrote:

Dear member,

I want to create coding for sum if in access.
Any can translate to me how to code sum if.
Table1 have tickectNo, item_partno and qty
Table2 have item_partno, qty1, qty2, and result.

When I click one button generate;
* sum (qty in table1) insert to qty2 in table2
* qty2 - qty 1 insert to result

pls help me to code in VBA

Marshall Barton

unread,
Nov 19, 2007, 8:49:51 AM11/19/07
to
hisham wrote:
>
>"Marshall Barton" wrote:
>
>> hisham wrote:
>>
>> >i want to sum if data in table in access database. means same item must be
>> >calculate sum.
>> >sum if like sum if in excel. how to write code?
>>
>>
>> Try this kind of expression:
>> Sum(IIf(condition, item, 0))
>>
>>
>I want to create coding for sum if in access.
>Any can translate to me how to code sum if.
>Table1 have tickectNo, item_partno and qty
>Table2 have item_partno, qty1, qty2, and result.
>
>When I click one button generate;
>* sum (qty in table1) insert to qty2 in table2
>* qty2 - qty 1 insert to result


VBA would be a slow and complicated way to do that kind of
calculation. Instead, you should use a query to sum a
column of values in a database table. Even then the result
should not be saved back to any table.

I guess what I am trying to say is that the way you would
create a spreadsheet does not work when you are creating a
database. You need to do some homework or take a class in
database design and using queries before you start trying to
do the kinds of things you are asking about.

0 new messages