Results 1 to 13 of 13
  1. #1
    hyman is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    8

    Question Access report problem

    Final - forum.zip

    Why cannot function DAvg work when data type of the field, which is applied within the "criteria", is combo box (mutiple choices are allowed)?


    It works well when data type of the applied field is text or combo box (mutiple choices are not allowed)?
    See the error in attached report "overall rating"!
    Last edited by hyman; 08-30-2012 at 04:31 PM.

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Take a look at Aggregate (Totals) Functions in Access's built-in help files. These allow you to group records on certain fields, and then do a mathematical computation on those groups (like Sum, Count, Average, Min, Max, etc).

  3. #3
    hyman is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    8
    I tried with the function of DAvg. But it did not work with the "criteria" part.
    Here is my function:
    =DAvg("[Warehouse]![Footprint overall site]";"Warehouse";"[Warehouse]![Industry]=' " & [Industry] & " ' ")

    ps. "Warehouse" is the table name. Now I am creating the function under a report. The field of "Industry" is a combo box, whose choices are retrieved from the table of DataDictionary.

    It works well work when replacing "Industry" by normal text field.
    How should I rephrase expression of the bold part?

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    The field of "Industry" is a combo box, whose choices are retrieved from the table of DataDictionary
    Where exactly is this "Industry" combo box found? I think you need to qualify it, with where it is coming from.

  5. #5
    hyman is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    8
    It is from the table of "Warehouse". I create my report based on this table.

  6. #6
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Is it a single record table?
    If not, how does the formula know which value for "Industry" to use?

  7. #7
    hyman is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    8
    No, it is not a single record table! But I include the field of "Industry" in the report. So the formula knows which value for "Industry" to use.

    The key of the issue is: data type of the field of "Industry".
    The current data type of the field of "Industry" is combo box (multiple choices).
    If I set data type as normal text and input content myself (instead of selecting), my formula works well.

    So how realize my goal with data type of combo box?

  8. #8
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    If I set data type as normal text and input content myself (instead of selecting), my formula works well.
    I think you are still leaving out some important details. A Report is not editable, so you cannot make a Combo Box selection on a Report.
    You can on a Form, though. Do you have some sort of selection Form that you are using to make selections to run your Report?
    If so, what does your VBA code look for that?

    Also, which section of the report are you placing this average calculation in?

  9. #9
    hyman is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    8
    I uploaded the file. I think it will explain my problem. Sorry for the confusion.

  10. #10
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Unfortunately, I cannot download files from my current location (corporate security policy). If you can explain what is going on, I may be able to help you sort it out.

  11. #11
    hyman is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    8
    Sorry for my late reply.
    I use below formula on my report:
    =DAvg("[Warehouse]![Footprint overall site]";"Warehouse";"[Warehouse]![Industry]=' " & [Industry] & " ' ")

    "Warehouse" is the name of my table. "Industry" is a field of my table. Data type of "Industry" is Combo box. If multiple values are not allowed within this Combo box, my formula works well. However, it does not work if multiple values are allowed within this Combo box.
    Unfortunately, multiple values have to be allowed with my database. So I would like to know how I should rephrase my formula.

  12. #12
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    But where is this combo box located?
    What do you mean when your say it can have multiple-values? Did you set it to be a multi-valued field (see here: http://office.microsoft.com/en-us/ac...010149297.aspx)?
    If it is a multi-valued field, I do not think I can help you. I avoid those pretty much at all costs, and have never used them. To me, they just seem to make things a lot harder than they have to be.

  13. #13
    hyman is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    8
    Yes, it is a multi-valued field. I guess I should set the field differently!
    Anyway! Thank you for your patient replies!

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

Similar Threads

  1. Replies: 1
    Last Post: 05-05-2011, 02:54 AM
  2. Report Problem
    By access_man in forum Access
    Replies: 7
    Last Post: 11-14-2010, 12:07 PM
  3. Problem with sub-report
    By samo1215 in forum Reports
    Replies: 0
    Last Post: 06-27-2010, 01:11 PM
  4. Report Problem
    By tlitman09 in forum Reports
    Replies: 0
    Last Post: 02-20-2007, 09:26 PM
  5. Replies: 1
    Last Post: 04-05-2006, 01:58 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