By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,092 Members | 1,057 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,092 IT Pros & Developers. It's quick & easy.

Sending selected items from listbox to report

P: n/a
Hi!

From a listbox I'd like to send only selected items to a report.

Items will include:

OrderNr,Date,EmployeeNr from tblOrders
ZipCode,City from tblZipCodes
Name,Adr,ZipID from tblCustomers
OrderNr,ItemID,Amount,Price,Discount from tblOrderDetails
ItemName from tblItems
Must I make a SQL in code in order to obtain this?

All data in listbox will be retrieved from underlying tables,

tblOrders,tblCustomers,tblItems,tblOrderDetails and tblZipCodes.

Any suggestions?

Me.Name
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Easy enough to use one value from the list box to filter your report, but
not sure how practical it is for multiple selections. Commonly, apps use
two approaches.
1. A continuous form with a checkbox to select each desired record for
the report, or..

2. A pop-up form with an unbound form whose unbound controls are used as
the criteria parameters for the report's underlying query.

Either one will result in a filtered record source for your report.

-Ed

"Geir Baardsen" <ge***********@hotmail.com> wrote in message
news:35**************************@posting.google.c om...
Hi!

From a listbox I'd like to send only selected items to a report.

Items will include:

OrderNr,Date,EmployeeNr from tblOrders
ZipCode,City from tblZipCodes
Name,Adr,ZipID from tblCustomers
OrderNr,ItemID,Amount,Price,Discount from tblOrderDetails
ItemName from tblItems
Must I make a SQL in code in order to obtain this?

All data in listbox will be retrieved from underlying tables,

tblOrders,tblCustomers,tblItems,tblOrderDetails and tblZipCodes.

Any suggestions?

Me.Name

Nov 13 '05 #2

P: n/a
"Geir Baardsen" <ge***********@hotmail.com> wrote
From a listbox I'd like to send only selected items to a report.


You haven't explained completely what you intend to do, but if I understand
correctly, you will have a listbox that has as its rowsource an SQL query
that brings together several tables; your listbox is a multi-select listbox,
and you want to make multiple selections; you want to print the select
records, which are rows from your listbox.

If the above is correct, one way to do this would be to use your original
SELECT query to fill a table - I'll call it qryFillTable.

a. Create the table with the fields you want from your query. You can also
create a "Make Table" query out of your original query using the Query
Designer to do the work automtically. I'll call it tblListBox.

b. Add a field to the end of the table, a yes/no field, "Selected"

c. Change the rowsource of the listbox to the table name

d. When you open your form, run three statements:

DoCmd.RunSQL "DELETE * FROM tblListBox"
DoCmd.RunSQL "INSERT INTO tblListbox SELECT * FROM qryFillTable"
myListBox.Requery

Your listbox is now filled with your query, plus you have an "extra" field
in your table, 'Selected'. Each time that you select a row in the listbox,
set the selected field to True. When you are ready to print your report,
use as your recordsource "SELECT * FROM tblListBox WHERE Selected=True"
Darryl Kerkeslager
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.