Report:Sum() doesn't work when recordset based on adodb command object

T

Tom Grillot

I have a report for which the recordset is an adodb command. The code looks
like this:
Private Sub Report_Open(Cancel As Integer)
Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = CurrentProject.Connection
.CommandType = adCmdStoredProc
.CommandText = "spQtrlySvcRpt_3"
Set Me.Recordset = .Execute
End With

The report populates all the fields correctly, but when I try to get a sum
in the Report Footer I get "#Error":
----------Report Footer------------------------------
Textbox Control Source: =sum([Cnt])
Where [Cnt] is a valid field in the recordset.

Any help is appreciated.
Thanks,
Tom
 
V

Van T. Dinh

(guessing only ...)

Do you have a TextBox Control (in the Detail section ???) in the Report with
the name
[Cnt] also?

If you do, try renaming this TextBox to something else, e.g. [txtCnt]
 
T

Tom Grillot

Yes, I do, and I've tried that. I've ended up just stepping through the
report's recordset and totaling the count in the ReportFooter_Format event.
Seems like a kluge, but it works.
Thanks,
Tom


Van T. Dinh said:
(guessing only ...)

Do you have a TextBox Control (in the Detail section ???) in the Report
with the name
[Cnt] also?

If you do, try renaming this TextBox to something else, e.g. [txtCnt]

--
HTH
Van T. Dinh
MVP (Access)



Tom Grillot said:
I have a report for which the recordset is an adodb command. The code
looks like this:
Private Sub Report_Open(Cancel As Integer)
Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = CurrentProject.Connection
.CommandType = adCmdStoredProc
.CommandText = "spQtrlySvcRpt_3"
Set Me.Recordset = .Execute
End With

The report populates all the fields correctly, but when I try to get a
sum in the Report Footer I get "#Error":
----------Report Footer------------------------------
Textbox Control Source: =sum([Cnt])
Where [Cnt] is a valid field in the recordset.

Any help is appreciated.
Thanks,
Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top