Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

adding a calculation on form

Posted on 2013-01-30
8
Medium Priority
?
294 Views
Last Modified: 2013-01-31
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
0
Comment
Question by:davetough
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 11

Expert Comment

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

=DAvg("[Time Spent]","Table1")
0
 
LVL 85

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 400 total points
ID: 38836297
You could use a DSum:

Msgbox DSum("[Time Spent]", "Table1", [Item Code]='101')

Or if the form is bound to that table, and you want too get the Item Code dynamically:

Msgbox DSum("[Time Spent]", "Table1", [Item Code]='" & Me![Item Code] & "'')
0
 
LVL 11

Accepted Solution

by:
datAdrenaline earned 1600 total points
ID: 38836887
"You could use a DSum"

I thought the Questioner wanted the average of all in Table1? ... but it is unclear about whether or not to filter on the item code.

---

So, if filtering is the desired result, then you can apply the filter LSM created in the DAvg() function:

=DAvg("[Time Spent]","Table1", [Item Code]='" & Me![Item Code] & "'')
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:davetough
ID: 38839230
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
0
 

Author Comment

by:davetough
ID: 38839555
will post another question-thank you
0
 
LVL 11

Expert Comment

by:datAdrenaline
ID: 38839642
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] & "'')
0
 

Author Comment

by:davetough
ID: 38839730
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
0
 
LVL 11

Expert Comment

by:datAdrenaline
ID: 38842376
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!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question