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!

Calculate a sum in a forms column 2

Status
Not open for further replies.

rew2009

Technical User
Apr 21, 2009
114
US
I am trying to calculate a sum of values in column in an access form but can’t figure out the syntax. The access form displays the records from a table called “Apts” in a Microsoft SQL database and works fine. However, I tried to add a calculate button in the form to sum a numeric field called “Tot_val” with a filter called “OwnerName” and put the result in a textbox in the form called “Text20”, but I am not sure of the syntax. I am looking for something simple like:

select Sum(Tot_val) from Apts where OwnerName=Me.Text10.value

and have the result inserted into Me.text20

Thanks for your help, rew2009
 

I think the DSum function would work here.
Something like this?
Code:
=DSum("Tot_val", "Apts", "OwnerName = '" & Me.Text10 & "'")

Randy
 
How are ya rew2009 . . .

[blue]Text20[/blue] should be an unbound control as calculations should never be saved in a table. Assuming a previously filtered form ... the [blue]Control Source[/blue] of Text20 should be:
Code:
[blue]   =Sum(Nz([Text10],0))[/blue]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top