Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 15th, 2007, 10:13 PM
Registered User
 
Join Date: Jan 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default open a report from a list box

I populated the list box using AllReports, etc. and I have two command buttons, one for Preview and one for Print on the form. How do I pick off the name of the report from the list box? I have tried using a variable to equal the highlighted column on the list box, but when I try to open the report all I get is the name of the column, not the content of the column selected. The following is the basic code I have been trying to use. What am I doing wrong?

Private Sub Command0_Click()

    Dim rptReport As String
        rptReport = " & listObjects.Column(2)"

    DoCmd.OpenReport rptReport, acPreview

    DoCmd.Close acForm, "ReportForm"

End Sub



Bob Peterson
Foster, RI
[email protected]
 
Old January 16th, 2007, 12:37 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Dim rptReport As String

rptReport = Me.MyListBox.Column(2)

DoCmd.OpenReport rptReport, acPreview
DoCmd.Close acForm, "ReportForm"

The way you have it now, rptReport = the string " & listObjects.Column(2)", and not actually what is in the listbox.

HTH


mmcdonal
 
Old January 16th, 2007, 06:17 PM
Registered User
 
Join Date: Jan 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

To: mmcdonal

Thank you for the help. It is always very gratifying to have something work. This is part of a program for my volunteer Fire Company.

Bob Peterson
Foster, RI
[email protected]





Similar Threads
Thread Thread Starter Forum Replies Last Post
copy a list box from a form to a report bjcountry Access 1 April 18th, 2008 03:14 PM
multi-column list box values moved to 2nd list box sbmvr Access VBA 1 May 14th, 2007 01:58 PM
Open the "Open File" dialogue box piratelordx Access VBA 4 March 14th, 2006 10:08 PM
List Box in Report mateenmohd Access 3 April 23rd, 2005 07:00 AM
List Box in a Report abhiinbwir BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 4 July 19th, 2004 12:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.