Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    zkrucz is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2016
    Posts
    103

    Need SUMMARY VALUE of costs


    I have a question regarding how to create a summary of costs TABLE by Job# of: LABOR and MATERIALS from a Table that has multiple entries for the same Job#. I need that Summary value to be able to compare to the Quoted amounts (in another Table).

    What I am looking for is similar to the CrossTab summary but not a static value which would require running the CrossTab query every time to get an answer. And, I need it to be in a Table form so that I can create Forms using that value.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Aggregate data should not be saved to table but calculated when needed. Forms can be built from CROSSTAB but data in CROSSTAB is not editable.

    Why can't you use Sum() function on form? Can use DLookup to pull quoted value from other table.

    Not really clear what you need.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    zkrucz is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2016
    Posts
    103
    @VIP
    Thanks for the feedback. Let me explain why I have these issues.
    We use iPads for our field staff to send in data. Unfortunately (for Access DB), the service provider uses horizontal style (spreadsheet) format. The incoming data is imported/append into a jobs Table which results in duplicate Job#s because any job may be completed in in pieces/phases. I want to be able to aggregate key costs (Labor, Materials, Inventory, Equipment) in order to figure out if the Quoted Job# resulted in profit or loss, using a Form.
    I tried using the Sum() function in a Form an I get an error: (#Name?)
    The Fields which I described above are formatted as Currency data type.
    So, can you steer me in the right direction for me to get aggregate values in my Form. As an example, the Sum(J_Materials) aggregate should return a value of $519.00
    Click image for larger version. 

Name:	Table J.JPG 
Views:	13 
Size:	64.8 KB 
ID:	41775Click image for larger version. 

Name:	Form J.JPG 
Views:	13 
Size:	13.7 KB 
ID:	41777
    Attached Thumbnails Attached Thumbnails Form J.JPG  

  4. #4
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,175
    Try a DSUM : = Dsum("Fieldname","Tablename", "Crit")
    example
    = DSum("J_Labor", "Table_Jobs", "[Job #* = """ & me.txtJobNr & """")
    given the control name for Job # on your form is txtJobNr, if not state there the name of the control on your form that holds the critirium

  5. #5
    zkrucz is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2016
    Posts
    103
    @NoellaG

    Thanks for your feedback, I modified your example to match the Materials example above:

    =DSum("J_Materials","Table_J","[Job # = """ & [me].[txtJobNr] & """")

    However, I still get the same error: #Name?

    Did I mess up my statement (above)?

  6. #6
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,165
    =DSum("J_Materials","Table_J","[Job #] = """ & [me].[txtJobNr] & """")

    Looks like NoellaG had a typo and you omitted the closing square bracket after [Job #

    You'll need to make sure the field names and text box names in the dsum match what they actually are in your project.

  7. #7
    zkrucz is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2016
    Posts
    103
    @NoellaG

    I tried anothe rapproach by creating a Summary query and trying to turn it into a table, but I am getting null values. When running the query to create the Table, I am being asked to populate all the cost fields. And even when I try to populate them with random values to see the imapct (say I entered "1" in all cases), the resulting Table sill has null values.Click image for larger version. 

Name:	COST Query1.JPG 
Views:	10 
Size:	28.5 KB 
ID:	41779Click image for larger version. 

Name:	COST TableSumm Query.JPG 
Views:	10 
Size:	15.8 KB 
ID:	41781Click image for larger version. 

Name:	COST TableCost_SUMM.JPG 
Views:	10 
Size:	24.9 KB 
ID:	41780

  8. #8
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,235
    Try "SELECT Table_J.[Job #], Sum(Table_J.J_Materials) AS JobMAterials, Sum(Table_J.J_Eguipment) AS Job_Equipment, Sum(Table_J.J_Labor) AS Job_LaborFROM Table_J
    GROUP BY Table_J.[Job #];"

    Please see attached.

    Cheers,
    Attached Files Attached Files
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Can't use Me. in textbox expression. This is a VBA alias for object code is behind. Drop Me. and expression should work

    I prefer apostrophe to doubled quotes.

    =DSum("J_Labor", "Table_Jobs", "[Job #] = '" & [txtJobNr] & "'")

    Advise not to use spaces nor punctuation/special characters in naming convention.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    zkrucz is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2016
    Posts
    103
    @Gicu VIP
    Hey, thank you! I got the aggregate Query to work (see below). Now, how can I get this to create a Table for me so that I can use the Table fields for my form?Click image for larger version. 

Name:	COST COST_SUMM Query.JPG 
Views:	10 
Size:	25.3 KB 
ID:	41783

  11. #11
    zkrucz is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2016
    Posts
    103
    @June7 VIP

    Hmm, I tried your expression and I still get the #Name? error....

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Then Access cannot find control named txtJobNr. What is actual name of control? Is it same as field name? Try the field name.

    =DSum("J_Labor", "Table_Jobs", "[Job #] = '" & [Job #] & "'")

    There is no need to create a table. Use query like a table, except cannot edit data in an aggregate query.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,235
    Sorry, you tried what expression where? You don't need to create another table to use the totals query in a form, just set it as the form's recordsource then in the form use the query's fields as the control source for the text boxes.

    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  14. #14
    zkrucz is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2016
    Posts
    103
    @Gicu VIP

    I guess I don't know how to access Queries for my Forms (design), then. When I open FORMS/Design i can only access existing Tables, there are no existing queries. What am i missing here?

  15. #15
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,235
    You have a queries tab on the Show Tables pop up window, slick on that and you will see it.

    Click image for larger version. 

Name:	AddQuery.PNG 
Views:	8 
Size:	30.5 KB 
ID:	41784
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Calculate shipping costs by zip code
    By joecamel9166 in forum Access
    Replies: 19
    Last Post: 04-19-2016, 01:35 PM
  2. calculating total job costs.
    By Homegrownandy in forum Access
    Replies: 9
    Last Post: 11-05-2015, 02:10 AM
  3. Help with adding costs up for each machine
    By cretam in forum Access
    Replies: 12
    Last Post: 06-18-2013, 07:02 PM
  4. Roll up costs with vba
    By nigelbloomy in forum Programming
    Replies: 1
    Last Post: 07-31-2012, 01:03 PM
  5. Report w/o multiple ship costs
    By stattech in forum Reports
    Replies: 1
    Last Post: 06-22-2010, 04:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums