Link to home
Start Free TrialLog in
Avatar of davetough
davetough

asked on

adding a calculation on form

hello,
have attached database-
open database and a form comes up- click Item code and name button-
( enter 101 for item code and jim for name)

a Form comes up that displays avg time it takes Jim to work on item code 101-
question:
Is there a way to display also on this form? the total avg time it takes all names listed in the table?
Thank you,
DB101.accdb
Avatar of datAdrenaline
datAdrenaline
Flag of United States of America image

On your Form2 you can create a text box control with a Control Source expression of:

=DAvg("[Time Spent]","Table1")
SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of davetough
davetough

ASKER

the first answer worked fine and then I realized I did want to filter on item code-
am attaching error I am getting- can see what am doing wrong- have tried LM solution too and not working-
thank you
error.docx
will post another question-thank you
sorry about the error.  the Me keyword is valid in VBA, however in a Control Source expression, you use [Form]

=DAvg("[Time Spent]","Table1", [Item Code]='" & [Form]![Item Code] & "'')

or, you  just drop the form reference since your scope is the current form ...


=DAvg("[Time Spent]","Table1", [Item Code]='" & [Item Code] & "'')
thanks - you know I am still getting error-
can you insert code into txtbox on form and attach db back here?

also just to confirm I am doing this right -am inserting code into the control source of the unbound textbox on form ( form2)
thanks
This ...

=DAvg("[Time Spent]","Table1", [Item Code]='" & [Form]![Item Code] & "'') 

Open in new window


Should be this ...

=DAvg("[Time Spent]","Table1", "[Item Code]='" & [Form]![Item Code] & "'") 

Open in new window


Pay close attention to the quotes!  It seems that LSM inadvertently did not balance the quotes and I copy pasted from him <dazed> ... So, I think I got it right this time!  {note: I am not in a position to post a sample, so hopefully this will do the trick!