Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    tonygg is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    115
    Thanks. I posted one of the calculations in an earlier post - Function OrderLevelDiscountsPercentCalc(...). Please see above



    Am I right to understand you are saying I can embed this code into a query? That is great. How do I do that so it passes the values into the function and puts the results into to the results.

    Thanks again.

    Tony

  2. #17
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I am saying the VBA code is probably not needed at all. Do the calculations with expressions in query or textbox ControlSource.

    I am not sure what that function is calculating. Are you trying to summarize order details? Summary calculations should be done with aggregate (GROUP BY) Totals queries or with report design.
    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. #18
    tonygg is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    115
    Ok. I guess I am not sure how practical it would - sorry if I am wrong. I would be really very happy if it was. I will give an example in English and would really appreciate it if you can sense check it is feasibility:

    An example is to apply a proportion of any order level discounts that should be attributed to a product.

    In order to do this I need to find all the orders that have this product in them. For each order found add up the total lines ordered (regardless of product) then divide it by the number units bought to see the proportion due to this product. These need to be summed up across all the orders and then the result is the value to display.

    A second example find the highest price paid for any product (which can be bought in 4 different ways).

    To do this you need to again find all orders for the product and then compare each order to find the one with the highest selling price for each buying choice (1 of 4). Not all products have all buying choices and so only once you have gone through all the buying choices for all the orders can you then decide which is in fact the highest unit price paid.

    I guess each of these require access to multiple other tables and need looping through multiple rows in those tables.

    Do these sound practical in expressions?

    How does one do this if it is impractical to have it in expressions?

    Many thanks

    Tony

  4. #19
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I expect queries can do the calculations you describe. Or report using Grouping & Sorting with aggregate calcs. Some aggregate functions are Sum, Avg, Max, Min.
    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.

  5. #20
    tonygg is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    115
    Great. I know how to the simple if a + B = c expressions but I don't really understand how to create the nested looping through different tables and retain intermediate calculations. Would it be possible for you to show me an example so I can see the structure? Many thanks Tony

  6. #21
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    There is no 'nested looping', there is a query (or multiple queries) or there is report design.
    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.

  7. #22
    tonygg is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    115
    Ok So if I understand correctly it is not appropriate to do what I need through queries. I guess after all this I am back to square one. You indicated report design may be the solution. Can I achieve my original goal if I change the datasheet into a report? If so could you be so kind as to show me the outline logic to be able to update the columns (per row) of a report and insert rows into the report. Thank you Tony

  8. #23
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Report design has Grouping and Sorting feature. Aggregate calcs can be done in report and group header/footer sections. Textbox in detail or group section can reference the aggregate calc textboxes to do percentage calcs.
    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.

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

Similar Threads

  1. updating subform in datasheet/Continuous view
    By Avizan05 in forum Programming
    Replies: 2
    Last Post: 05-02-2014, 07:04 AM
  2. Updating a field on Datasheet
    By hascons in forum Forms
    Replies: 3
    Last Post: 04-20-2014, 12:55 PM
  3. Replies: 9
    Last Post: 02-28-2012, 01:45 PM
  4. Updating form from datasheet
    By srcacuser in forum Forms
    Replies: 10
    Last Post: 11-16-2011, 12:59 PM
  5. Replies: 0
    Last Post: 12-25-2008, 10:05 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