Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 April 21st, 2005, 10:27 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default List Box in Report

How can create List Box in Report ?

Report run by the query.

query is

select fieldname,....... from table
WHERE dbo_EMP.DEPT=[Department ]

it ask dept name.
I want the when it ask dept name, dept name
should be displayed in List Box.
User select the dept name from the list box.
what changing in the report properties ?

Please help.

regards.

Mateen






 
Old April 21st, 2005, 10:34 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

My approach to requirements like these has been to create a form with the listbox on it, and a button that will open the report and pass the parameters specified by your list box.

What I think that you are looking for is a Message Box when the report opens with a listbox on it, which I don't think is possible to do, but I would be happy to find out I am wrong.

Hope that helps

Mike

Mike
EchoVue.com
 
Old April 21st, 2005, 11:25 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Create a list or combo box on a form, and make sure it is bound to the column you will need to generate your report. Usually it is the primary key (column 1) but may also be meaningful data (column 2).

Then place a button on your form to open the report. The wizard may ask for you to make an association from the combo box on the form, but if it doesn't, just add this code:

'=====

Dim stDocName As String
Dim stLink As String
Dim intMyCombo As Integer 'for column 1

'or

Dim stMyCombo As String ' for column 2

intMyCombo = Me.MyComboBox
'or
stMyCombo = Me.MyComboBox

stLink = "[MyFieldValue] = " & intMyCombo ' for integer

'0r

stLink = "[MyFieldValue] = " & "'" & stMyCombo & "'" ' for string

stDocName = "rptMyReportName"
DoCmd.OpenReport, stDocName, acPreview, , stLink
'=====

In this example, MyFieldValue is the column in your report that you want to specify criteria for. This will work if your report is based on a query or table.

You cannot put this in a report, but must put it on a form.

HTH

mmcdonal
 
Old April 23rd, 2005, 07:00 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your response.

I try your code.
I make form and one button. and button click event
I write your code like this.

Dim stdocname As String
     Dim stlink As String
     Dim intmycombo As String

     intmycombo = Me.mycombobox // compile error, method or data
                                      member not found


     stlink = "[dbo_emp.dept] = " & "'" & stmcombo & "'"
     stdocname = "dept_report"
     DoCmd.OpenReport , stdocname, acPreview, stlink

it give above error.

Report name is dept_report
on click button it display print preview

query is

SELECT * FROM dbo_EMP;

query will like this

SELECT * FROM dbo_EMP where dbo_emp.dept=[deptname];

or query will without where clause.

I try both, but error is same.

regards.

Mateen









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 a report from a list box Bob Peterson Access VBA 2 January 16th, 2007 06:17 PM
List Box in a Report abhiinbwir BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 4 July 19th, 2004 12:57 AM
Search using drop down list box and a text box tcasp Classic ASP Basics 1 July 31st, 2003 02:58 PM





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