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

How to use a recordset as the basis for a report

Status
Not open for further replies.

nikkiswin

Technical User
May 22, 2002
7
0
0
GB
I have a form in which Users type/select the criteria for a report. There is a Preview cmd button on the form which generates a SQL string based on the User's selections and opens a recordset.
The recordset is opening and returning the correct data.
HOWEVER, I can't find a way to then open the report with the RecordSource of the report set to this recordset. I am currently using
DoCmd.OpenReport strRptName,acViewPreview to open the report.

I have tried setting the RecordSource property of the Report to strSQL (my generated SQL String) and to rsReport (the name of the recordset). Both strSQL and rsReport are set as Public variables.

I have also tried setting Me.RecordSource=rsReport in the Report_Open event but this subroutine doesn't appear to get called by the DoCmd.OpenReport...

Is there an easy fix for this that doesn't involve using Querydef???

 
3 of many possible ways

place your sql string in a textbox on the form then in the reports on open event refer to the textbox

me.recordsource = forms!formname!textboxname

or

I would think in the forms on open event

me.recordsource = strsql ' your public variable

if the recordset is being set on the form then

me.recordset = forms!formname.recordset

will work as well

good luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top