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

Print a report directly from table data without displaying a report

Status
Not open for further replies.

deepmots

Programmer
Jun 9, 2005
4
US
Hi,

I have the following thing to accomplish -
1. One table is populated with the data already.
2. I have to loop this table to get the records one at a time.
3. I have to directly dump this record data into a report.
4. This report should be sent to the printer immediately without displaying on the screen.
5. Loop through till all the records from the table have been read.

Can you please advise, how to accomplish this?

Thanks,
-Deepak
 
Create a report with the table as RecordSource.
Then opening the report with acViewNormal instead of acViewPreview will print it directly.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
deepmots,

Are you saying that each record will comprise a separate report?

Ken S.
 
Hi,

This is how I want it...

The reports have a specific templates. One report per record in the table has to be printed at a time.

Each record in the table contains the image (logo of the company) and another image (type of the comapny) to be printed on the report at runtime based on their values in the record.

So, we have to loop through the table records and based on the name of the company, we have to select the report display the images on the report. The images are stored in the filesystem.

Can you suggest the best approach to follow?

Thanks,
-Deepak
 
You can try this:
Code:
Sub PrintMyReports()

Dim db As DAO.Database, rs As DAO.Recordset, strSQL As String, strFilter As String

strSQL = "Select * From tblReportData;"

Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL)

rs.MoveFirst

Do Until rs.EOF = True
    strFilter = rs![ID]
    DoCmd.OpenReport "rptTemplate", acViewNormal, , "[tblReportData]![id] = " & strFilter, acWindowNormal
    rs.MoveNext
Loop

rs.Close
Set db = Nothing

End Sub
 
Excellent.

Moreover, what if I need to assign the data coming from the database to the fields of the report at runtime, how to assign that?

 
You could use an unbound report. Then in the Do...Loop assign the fields to the controls of your report.

Reports("rptTemplate").contorls![test].Value = rs![test].Value
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top