Results 1 to 7 of 7
  1. #1
    Onno is offline Novice
    Windows 7 Access 2007
    Join Date
    Oct 2010
    Posts
    2

    Angry =IIf([Report].[HasData];Count([COL_NAME]);0)


    Hi,
    I'm trying to understand a bit of MS Access magic.

    I have a report where number of records in the report is crucial information. For this reason I want to display a count on the report header page. I have one report where I succeeded in doing so using a text box with the following data source property
    =IIf([Report].[HasData];Count([COL_NAME]);0)

    I have another report that was copied from the first that uses the exact same query. The text box now always displays #Error as the value. I have tried several variations on the data source property but the result is always the same: #Error. I have tried for example
    =IIf([Report].[HasData];Count([COL_NAME]);0)
    =IIf([Report].[HasData];Count(*);0)
    =IIf([Report].[HasData];Count("*");0)

    Is there a way to debug this problem? I have spend countless hours trying to figure out why it doesn't work in the second report but really got step further to understand the mechanisme behind counting records in MS access reports.

    Is there a debugger of some sorts where we can step into the count-function to see why this does not work.

    Thanks and Regards,
    Onno

  2. #2
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    I don't know if this is where your problem is or not, but those semicolons (;) should be commas (,).

    Assuming that doesn't fix the problem, does the Report actually contain any data? (If that does fix the problem, you can ignore this question and just mark the thread solved ).

  3. #3
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,046
    Hi,

    if you are using European settings, only in the VBA window function arguments are separated by ",". In the control source property of form/report controls and in calculated queries European settings demand a semi-colon ";" to divide the arguments of a function.

    To count the number of records in a report I never had trouble using the simple :

    =Count(*)

    greetings
    NG

  4. #4
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    Bah, silly Europeans. Always trying to do things the hard way, like using the metric system!

  5. #5
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    I don't think Onno is using European setting, because tried

    =IIf([Report].[HasData];Count([COL_NAME]);0)
    =IIf([Report].[HasData];Count(*);0)
    =IIf([Report].[HasData];Count("*");0)

    and fail.

    I did try =IIf([Report].[HasData],Count(*),0) and it worked.

  6. #6
    evander is offline Competent Performer
    Windows 7 Access 2003
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    206
    How interesting.

    It's my first time to know about "European" settings in Access.
    Great thing to know.

  7. #7
    Onno is offline Novice
    Windows 7 Access 2007
    Join Date
    Oct 2010
    Posts
    2

    Talking My bad

    As it turns out I can only use count in the report header or report footer. So my bad, I copied it to the wrong location.

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

Similar Threads

  1. Replies: 7
    Last Post: 07-22-2010, 01:14 PM
  2. Count and Sum in Report
    By Brian62 in forum Reports
    Replies: 3
    Last Post: 02-19-2010, 04:10 PM
  3. count with conditional
    By humpz in forum Reports
    Replies: 3
    Last Post: 08-02-2009, 08:11 AM
  4. How to count negative numbers in a report
    By planner67 in forum Reports
    Replies: 3
    Last Post: 07-01-2009, 07:00 AM
  5. how do i do a word count
    By clueless in forum Queries
    Replies: 0
    Last Post: 06-03-2009, 09:01 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