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!

Print Report from Listbox Selection - Access 97

Status
Not open for further replies.

tpearo

Technical User
Apr 24, 2000
124
US
I have a database that has a number of reports that get printed by various people. Is there anyway to create a form with a listbox that identifies each report by name and when the employee selects that item (report) in the list the report would then print? [sig][/sig]
 
Attach a event procedure for the list box to the click event, and then write the code to opne the repot in print mode - i.e. it sends it straight to the printer.
Another way to do that is to have a command button which then uses the listbox selection to print the report.

James :) [sig]<p>James Culshaw<br><a href=mailto:jamesculshaw@active-data-solutions.co.uk>jamesculshaw@active-data-solutions.co.uk</a><br><a href= Active Data Solutions</a><br> [/sig]
 
Any hints on what code would be used to send the listbox selection to print?
 

Here what I use for listing macros. just replace &quot;scripts&quot; by &quot;reports&quot; and you should be good to go.

Sub Form_Open(Cancel As Integer)
On Error GoTo Err_OF
Dim db As DATABASE
Dim I%
Dim contr As Container
Dim strReportList$
Dim StrReportName$
Dim Length%

DoCmd.Restore
Set db = CurrentDb()
Set contr = db.Containers(&quot;Scripts&quot;)

strReportList = &quot;&quot;
For I = 0 To contr.Documents.Count - 1
StrReportName = contr.Documents(I).Name
If Left(StrReportName, 5) = &quot;cmgt_&quot; Then
If strReportList <> &quot;&quot; Then strReportList = strReportList & &quot;;&quot;
Length = Len(StrReportName)
StrReportName = Right(StrReportName, (Length - 5))
strReportList = strReportList & StrReportName
End If
Next I

Me!RptLstBox.RowSource = strReportList

Exit_OF:
Exit Sub
Err_OF:
MsgBox Err & &quot; &quot; & Error, , &quot;Form Open&quot;
Resume Exit_OF
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top