Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2014
    Posts
    1

    Unanswered: Total # of records from a query in a report

    I am trying to figure out a way to display in a report the total the number of records that come from a query. For example i am running a query for automobiles sold in a month which works fine. Now i just need a total of those automobiles in a report.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    depends when / or where you need the total of these rows
    of its at the foot of a report and or group
    define a control in the grouping set its recordsource to =count(AColumnFromYourReport)
    where AColumnFromYourReport is A Column From Your Report

    if its at the start of the report, thats a bit trickier
    youll need to find the right event hook (its propbably the forms on open or on load event
    'declkare this as a global variable
    Dim NoRecords as Integer

    put this code in the event hook' note its nto tested so its may well be wrong
    'if its not recordsource, its rowsource or something similar
    me.recordsource.movefirst 'make certain we are at the first row int he recordsource
    me.recordsource.movelast 'move to the last to force the recordcoutn to be set
    NoRecords = me.recordsource.recordcount
    me.recordsource.movefirst 'make certtain we return to the first to make certain the reprot runs

    'then when/wherever you need to use the value refer to NoRecords
    'heck for all I know you may not need a separate variable as the recodcount property will have been set by the movefirst/moveelast
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •