Filter for just one Text box

  • Thread starter Thread starter meone
  • Start date Start date
M

meone

I'm not super familiar with vb and access, most of my experence is wit
webbased databases. What I am trying to do is have a text box in m
form footer do something like this, =SUM([field1]) but with a filte
ei: "WHERE field2=0". I can't find anyway to make this work, doe
anyone have any suggestions? thanks for your help
 
Hi,


= DSUM("field1", "TablenameHere", " field2=0 AND ... " )


note that AND ... is just an indication that you can AND / OR conditions,
you can definitively have just:

= DSUM("field1", "TablenameHere", " field2=0" )


but SUM, in a report, refers implicitly to the "actual group", DSUM
doesn't... so, you MAY have to add the group "description"

"field2=0 AND EventNumber=" & EventNumber & " AND UserName= """
& UserName & """"


just for illustration, for the third argument of DSum. Indeed, if the actual
"group" has EventNumber = 111 and UserName = toto, the criteria, once the
concatenations are resolved, would hold the string value:

field2=0 AND EventNumber=111 AND UserName="toto"


Also note that all the arguments of DSUM are strings, including the first
one (which can be an expression or a field name).


Hoping it may help,
Vanderghast, Access MVP
 
Hi !
Domain aggregate has criteria option.
You should replace 'TableName' with your form record source table or
query.

=Dsum("[TableName]![Field1]";"[TableName]";"[TableName]![Field2]=0") as
static criterion
Or with dependent criterion
= Dsum("[TableName]![Field1]";"[TableName]";"[TableName]![Field2]=" &
[FormName]![ControlName])

Aleksander
 
Back
Top