Results 1 to 5 of 5
  1. #1
    justinwright is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    104

    DCount on report - per line

    I've seen topics about Dcounting on reports but none of them seemed to apply.

    What I have is a report with a following (relevant) columns

    AGENT (number datatype, field name AGENT)
    6 Months
    12 Months

    It's a list of different agents that I want to count the number of occurrences of said agent in the table, tblData, adding that as a column to my report per line.

    For example, let's say Agent #1 occurs in tblData now, 2 months ago, 7 months ago, and 14 months ago. The report would list (under separate columns) 1 for the "6 Months" column and 2 for the "12 Months" column. This will be per line for each agent listed on the report.



    My DCount syntax (Control Source for the entry under the "6 Month" column) is

    Code:
    =DCount("*", "tblData", "AGENT = " & [txtAGENT] & " AND DATEENTRY >= #" &  [txt6mths] & "#")
    but I seem to be having trouble with it.

    txt6mths is just a hidden textbox I have on the report. txtAGENT is the name I assigned to the data for the AGENT column on the report.

    Anyone have any ideas? Any help is much appreciated.

    Justin

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Are you getting an error or the wrong result? Offhand, the formula looks fine if the fields are numeric and date (you said agent was numeric, I assume the other is date). The textbox contains a date value? Can you post the db here, or a representative sample?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    justinwright is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    104
    The only result showing is 12/30/1899 (a date) when I was looking for a number. I assume this is some sort of error placeholder though.

  4. #4
    justinwright is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    104
    Wait nevermind, I'm retarded and I had it set to short date. When I removed the formatting, it's just giving me 0 (when if its listed on the report, it's at least a 1 in both columns.

    EDIT: I was looking at older entires there too.. I really need some coffee today lol.

    In short, somehow my format got set to Short Date, and removing that solved my problem based on how I had it set up. Thanks for the super quick response as always Paul!

    Justin

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Glad you got it sorted out Justin.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Line chart in access report
    By drp in forum Reports
    Replies: 2
    Last Post: 11-29-2011, 09:37 AM
  2. Select line from a form for a report
    By drf3794 in forum Access
    Replies: 3
    Last Post: 03-17-2011, 11:01 AM
  3. Eliminate line breaks in exported report
    By thekruser in forum Reports
    Replies: 3
    Last Post: 09-28-2010, 08:57 PM
  4. Dcount on report
    By mattbrem in forum Reports
    Replies: 2
    Last Post: 06-06-2009, 01:33 AM
  5. Replies: 3
    Last Post: 03-24-2006, 08:40 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