count records in a report

  • Thread starter Thread starter Shivalee Gupta via AccessMonster.com
  • Start date Start date
S

Shivalee Gupta via AccessMonster.com

I have a report which is inturn calling a parameter query. I wish to open
the query with a text box on the side saying how many records are being
displayed.
I have used dcount like this:
MsgBox DCount("*", "displaying uname from tcode"), vbDefaultButton2, "Rows
Returned are"
But it is displaying a message box, Can I make a text box?
Please help.
Shivalee
 
hi,
you used the msgbox command. why are you supprised that it
is displaying a msgbox????
a message box is just another form. it is using a lable
control to display a caption.(the message). it is built
into vb and cannot be changed.
you can create your own message form, put a text box
control on it. and a lable control with caption 'the
records retured are'
you can use the docmd.openform instead of msgbox.
set the text box with
me.textbox1 = dcount ect
 
No I probably did not put it the right way. I have a form, from which I am
opening a report. This report is based on a query. For example, if I open a
query, it displays the total number of rows selected, but in case of a
report, there is no way of knowing how many rows were selected. The code
you have given is not understood by me. I cant use docmd.openform, cause I
am in the form. I also tried using docmd.openquery and then
docmd.openreport. I need a text box (and not a msgbox) on top of my report
saying these many rows were selected. I have dcount for a table and a query
and it is working for both . I have also used dcount in a msgbox for this
report, but that is not very user-friendly. My sub looks like this inside
the form's command button's click:

Private Sub displaying_uname_from_tcode_report_Click()
On Error GoTo Err_displaying_uname_from_tcode_report_Click

Dim stDocName As String

stDocName = "Displaying uname from tcode"
DoCmd.OpenReport stDocName, acPreview
MsgBox DCount("*", "displaying uname from tcode"), vbDefaultButton2,
"Number of Rows Returned are"

Exit_displaying_uname_from_tcode_report_:
Exit Sub

Err_displaying_uname_from_tcode_report_Click:
MsgBox Err.Description
Resume Exit_displaying_uname_from_tcode_report_

End Sub


can you suggest?
thanks,
shivalee
 
To display the number of records contained in a report, add a text box to
the report header or footer with a control source of:
=Count(*)
 
Back
Top