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!

Address Labels from a recordset 1

Status
Not open for further replies.

spruceni

Technical User
May 18, 2007
72
GB
Hi I have done a search but did not see or recognise what I am looking for.

I have created a recordset of client addresses using a query. I now want to use this recordset to print labels.
I can build a label sheet using the label wizard on some dummy table and call it "labelTestReport". I want to call this report from with in my code and feed it with my preselected recordset. It has all the necessary fields.

I assume you use something like

DoCmd.OpenReport "labelTestReport",acViewPreview --- etc

where you can pass in the recordset.

What is the structure of the call or am I way off in the wrong direction?

Thanks for any help


 
Well in some versions of access you can set the report recordset

in report

Code:
Private Sub Report_Open(Cancel As Integer)
dim mydb as database 
set mydb = currentdb
set me.recordset = mydb.openrecordset("Select ..... from ....")
 
Thanks for replying
I will try this when I get back to my code.
I use the entire record set as I have already preselected the records and the record set "rst" is already open.

set me.recordset = mydb.openrecordset("Select ..... from ....")

It's the from bit I am stuck on. Do I use from mydb.rst ?

can I get away with set me.recordset = mydb.rst
 
Hi Thanks for the help

Could not get the code inserted in the Private Sub Report_Open(Cancel As Integer)
to work. Kept saying that
me.recordset = mydb.rst --- rst was unknown

Anyway I redesigned the report and set its record set to the main query and then passed in the where clause in the
DoCmd.OpenReport "rptTestLabels", acViewPreview, WhereCondition:=varWhere

It all seems to work fine

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top