Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help in generating a report from recordset in access.

Status
Not open for further replies.

dsk525

Programmer
Mar 13, 2002
73
US
Hi
I have the following code written in access vb to print a report form the recordset. I have the record set defined and have the data too inside the recordset. The problem i have is that i need to assign the name of the recordset to the RecordSource property of the report . I have all the code in a seperate function.

Private Sub Report_Open(Cancel As Integer)
Me.RecordSource = Recordset.Name
End Sub

This is where i am trying to assign the RecordSource property with the recordset.This is done when the report is opened.

I could not find the Name property for the recordset. Some how i need to assign the RecordSource property with the recordset in order to generate the report.

I would really appreciate if any one could help. I have also the remaining code below.



Option Compare Database
Public Recordset As ADODB.Recordset

Public Function test()
Dim Connection As New ADODB.Connection
''Public Recordset As ADODB.Recordset

On Error GoTo errh

Set Recordset = New ADODB.Recordset

txtSQLD = "Select * from ClaimPayment where ClaimID = 'P08208'"


Connection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=E:\N_Data\EMR\emrdata.mdb"

Call Recordset.Open(txtSQLD, Connection, adOpenDynamic, adLockOptimistic)

DoCmd.OpenReport "rptClaimPaymentByNum", acViewPreview

Exit Function

errh:
'Code to close the recordset if open.
Recordset.Close
Set Recordset = Nothing
MsgBox Err.Description
MsgBox Err.Source
End Function
 
Set the recordsource property of the report with your "Select ..." statement, instead of, the name of the stored procedure.

mac
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top