Results 1 to 6 of 6
  1. #1
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    494

    Include field value from another query in report

    I have a report that is based off a query that has several hundred lines with values that I sum up. I also have another query that has manual adjustments. I would like to add the total adjustments for a particular customer to the end of the report and use it to calculate the final value.

    for example:
    1 20
    2 10
    3 07
    Total for customer 37
    Total manual adj 13


    Total after adj 50

    I am not sure how best to do this. If it is better to just reference the value somehow? I dont want to include it in the original query because i dont have a value for every line of the query.
    Thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Is every customer in the first query? Doesn't matter if not every customer in the second query. Can still join them, don't use INNER join.

    Otherwise, options:

    1. subreport

    2. DLookup or DSum expression in textbox
    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
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    494
    It is actually a list of miles. So the main report looks at all the car movement's and then just displays the movement for each customer. So you end up with anywhere from 10 rows to thousands of rows.
    I have used DLookup in the past but cant seem to get it to work like I want here

    I am trying =DSum("[FieldNameFromQueryThatHasTheNumberOfMiles]","qryThatWillFindAllManualAdjustmentForCustomers" ,"FieldNametoFind-CustomerName = " & [Forms]![Form]![NameOfFormThatWillHaveCustomerName])

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Why doesn't it work, what happens - error message, wrong results, nothing?

    Are those the actual field and query names? The hyphen might be an issue. Advise not to use spaces or special characters/punctuation (underscore is exception) in names. If used, enclose name in [].

    The form reference is wrong and doesn't include control name but really just need to reference the control name if it is on the same form as the textbox with the expression.

    If the value searched is text, need apostrophe delimiters.

    =DSum("[FieldNameFromQueryThatHasTheNumberOfMiles]","qryThatWillFindAllManualAdjustmentForCustom ers" ,"[FieldNametoFind-CustomerName] = '" & [control name] & "'")
    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. #5
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    494
    I am not sure why it wasn't working so I kind of changed how I access it. Those are not the real field names, I just used them because I thought they were more descriptive. I was trying to get a single number but have changed it to add up separate numbers (loaded and empty) and changed the fields I was looking at and I think I have it working.
    Not sure if I am liking it though because I might want to show the detail of the records instead of just a final number. You mentioned sub-report before. I have done sub-forms but never a sub report. I will give that a try but I am not sure if I can use the values in the sub-report to create a total with the values in the main report. For example, can I take the total from the main report and subtract the value from the sub report and get a number?

  6. #6
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    494
    Thanks for the help. I was able to figure out how to pull the field value from the sub report and now i have a detail list of the records in the sub- report and the total in a field in the main report to use for calculations.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 01-24-2013, 08:16 PM
  2. Replies: 2
    Last Post: 10-11-2012, 10:50 PM
  3. Replies: 6
    Last Post: 08-16-2012, 04:15 PM
  4. Replies: 3
    Last Post: 06-25-2012, 06:54 PM
  5. Replies: 3
    Last Post: 08-04-2011, 05:39 PM

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