By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,466 Members | 1,756 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,466 IT Pros & Developers. It's quick & easy.

Displaying a Sum from a Query to a Text Box

100+
P: 112
I am working with Access 2007. I am trying to have an unbound text box display results from a sum query on a form. I am creating a rental Database with a form that has the Renter info on it with a sub form for the dates and time of the renter. They are run off two tables one for the rental and one for the date/times. I have created a query that sums the rental hours used on each day for each function. Example: I have a renter that rents the facility for 4 day at 8 hours a day, my query totals 32 hours for that renter. So I created an unbound text box on my rental form that’s Control Source is:

Expand|Select|Wrap|Line Numbers
  1. =DLookUp("[SumOfHoursOfUse]","DatesSumQuery")
However, this only displays the first Renter sum no matter what record I am on. I need something to tie it to current Rental that it is being displayed. I would assume that it is the “FunctionID” which is my auto numbered field for each rental, but I do not know how to add it in?
Feb 7 '12 #1

✓ answered by NeoPa

The function you're using, DLookup(), has an extra parameter called Criteria which is for identifying records within the specified Domain. See Context-Sensitive Help for the function for the full details.

Please see [code] Tags Must be Used.

Share this Question
Share on Google+
3 Replies


NeoPa
Expert Mod 15k+
P: 31,186
The function you're using, DLookup(), has an extra parameter called Criteria which is for identifying records within the specified Domain. See Context-Sensitive Help for the function for the full details.

Please see [code] Tags Must be Used.
Feb 7 '12 #2

100+
P: 112
Ok I got it...
Expand|Select|Wrap|Line Numbers
  1. =DLookUp("[SumOfHoursOfUse]","DatesSumQuery","[FunctionID]=" & [Forms]![FunctionForm]![FunctionID])
It works, Thanks!
Feb 7 '12 #3

NeoPa
Expert Mod 15k+
P: 31,186
You clearly got both points well Redbeard :-) I'm glad I was able to help.
Feb 8 '12 #4

Post your reply

Sign in to post your reply or Sign up for a free account.