Dsum function

  • Thread starter Thread starter Ezekiël
  • Start date Start date
E

Ezekiël

Hi everybody,

Who can help me with the dsum function in vba?I can't get it quit right if i
use a select statement in the expression.

I would like to make a calculation by using 2 tables that are related. One
table contains prices of orders and the other table is a list with values
which i would like to calculate.

The code looks like this:

Dsum("[price]","orders","Id=me![cmbOrderId]")*
Dsum("Select....","pricegroups","? (I don't know what to fill this part")

Greetings,

Ezekiël
 
Ezekiël,

I am pretty sure the first section of the expression won't work
correctly as you have it, with the Me operator within the ""s. I
think you will need...
Dsum("[price]","orders","Id=" & me![cmbOrderId])

As regards the second part, to be honest I don't know whether it is
possible to use a SELECT statement within a domain aggregaet function
in this way. But without knowing more details of what you want, at
this stage I certainly can't imagine why you would need to... I mean,
I'm probably missing something here, but what can the Select statement
do that the DSum can't do by itself?

- Steve Schapel, Microsoft Access MVP
 
Steve,

Well, in the first table where i have prices of orders e.g.

I've got to order pipelines á $100,- every month. Therefor i have in a
second field the Idnr of the second table where i want the dsum lookup the
value of the month (1) multiplied by the second field of the second table
where i have values to calculate it for a year (12).
So what i want is $100,- * 1 * 12 = 1200

This go's for other values like quarter, weeks, days, etc.

E.g. $100,- * 4 (value for quarter)*3 (value to calc to a year)=1200

Will the Dsum achieve this?
Steve Schapel said:
Ezekiël,

I am pretty sure the first section of the expression won't work
correctly as you have it, with the Me operator within the ""s. I
think you will need...
Dsum("[price]","orders","Id=" & me![cmbOrderId])

As regards the second part, to be honest I don't know whether it is
possible to use a SELECT statement within a domain aggregaet function
in this way. But without knowing more details of what you want, at
this stage I certainly can't imagine why you would need to... I mean,
I'm probably missing something here, but what can the Select statement
do that the DSum can't do by itself?

- Steve Schapel, Microsoft Access MVP


Hi everybody,

Who can help me with the dsum function in vba?I can't get it quit right if i
use a select statement in the expression.

I would like to make a calculation by using 2 tables that are related. One
table contains prices of orders and the other table is a list with values
which i would like to calculate.

The code looks like this:

Dsum("[price]","orders","Id=me![cmbOrderId]")*
Dsum("Select....","pricegroups","? (I don't know what to fill this part")

Greetings,

Ezekiël
 
Ezekiël,

Do you mean something like this?...

DSum("[Price]*[Period]*[Multiplier]","PriceGroups","Id=" &
me![cmbOrderId])

Otherwise, give us an example of the SELECT statement you were going
to use... maybe that will help understand what you want.

- Steve Schapel, Microsoft Access MVP
 
Back
Top