Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to write the Dsum "WhereCondition" on Subform 1

Status
Not open for further replies.

rccline

Technical User
Jun 13, 2002
341
US
I would like to show the total of my subform on the main form.

I have tried to create a textbox on my subform using =Sum([WI])
I have seen and read examples, but in my case, this formula only returns the message: #error


I tried to use Dsum that I read in thread702-1778486.

The solution calls for an optional WhereCondition. Duane Hookem wrote:

=DSum("Amount","Your table or query name","Optional WhereCondition")

The following returns the sum of the WI field in the entire database.
DSum("WI","myQuery","InstrumentID"

These return the error #Name?
DSum("WI","myQuery","InstrumentID","Me.InstrumentID")
DSum("wi","myQuery","InstrumentID=" & [Me].[InstrumentID])


I do not know how to write the Optional WhereCondition.
Guessing how to write the optional WhereCondition isn't working for me.

I want to sum the WI for the current record only.
Grateful for help with this.

Thank you.

Robert



 
Try this assuming InstrumentID is numeric and myQuery is the recordsource of the subform:

=DSum("wi","myQuery","InstrumentID=" & [InstrumentID])

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Thank you very much Duane! That worked like a charm.

Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top