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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameter query as a report recordsource???

Status
Not open for further replies.

davidmreid

Programmer
Nov 30, 2001
16
0
0
US
How can I use parameter query as a report recordsource? I tried the following from Dev Ashish with no luck:

Reports: Use a recordset as report's datasource

A recordset has a seldom-used property, Name, that gives you the table, query or SQL string that the recordset was opened with. And this is exactly what is needed to set a recordsource.

In the Open event of the report:

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

In a standard module:

'Code Courtesy of
'Andy Baron
'
Public grst As Recordset

Public Sub testreport()
Set grst = CurrentDb.OpenRecordset( _
"Select * from tblTest1 where longfield=4")
DoCmd.OpenReport "rptTest1", acViewPreview
grst.Close
Set grst = Nothing
End Sub

Thanks for the help!
 
Hi try this

DoCmd.OpenReport ("YourReport"), acViewPreview, "YourQueryOrYourSQLStadementVariable" Best Regards

---
JoaoTL
mail@jtl.co.pt
My MS Access Site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top