Thank you very much MGFoster.
I tried according to our idea, it works only partly. What I really want is,
when one clicks one row of the listbox, the item, say, product name will be
displayed in the subform in the first line together with its unitprice, when
one clicks another row of the listbox, the other product name comes to the
second line with its unitprice too, and so on.
I thought using INSERT INTO would make it possible. I mean to insert records
from the product table (which is the source of the listbox control) into a
query say called "order_detail_query" which is the source of the subform.
Howerver, as a beginner on sql, it is tough for me to complete my plan. I
understand your idea and appreciate your help very much. I won't give up.
Maybe it is a good topic, everybody is welcome.
Thanks to Rich too,
Paul
----- Original Message -----
From: "MGFoster" <me@privacy.com>
Newsgroups: comp.databases.ms-access
Sent: Wednesday, September 15, 2004 6:18 PM
Subject: Re: help! pass listbox item to a subform
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I'd set up the ListBox's RowSource property to return both the product
name and it's price. Hide the Price by setting its column width to
zero. The RowSource SQL would look something like this:
SELECT ProductName, Price FROM Products
The ListBox's ColumnWidths would be something like this:
Column Widths: 1.5";0"
Zero indicates the Price will not show in the ListBox.
I used inches (") - change to whatever metric you normally use.
The following assumes the ListBox is not a multi-select list box (IOW,
only one item can be selected at a time). In the subform controls, pull
the data from the ListBox like this:
ProductName:
The product name is in column zero (1st column in SELECT clause)
ControlSource: =Parent!ListBoxName.Column(0)
Price:
The price is in column 1 (2nd column in SELECT clause)
ControlSource: = Parent!ListBoxName.Column(1)
See the Access Help articles on "Parent" and the Column property of the
List/Combo Box controls.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQUhrVYechKqOuFEgEQJl1wCfeZ+YYg57qs5xkrhcZ+u8X+ pxKJoAn0HY
Q+K0OgrXNsOhU1ms+wTjA1e7
=T/DR
-----END PGP SIGNATURE-----
Paul T. Rong wrote:
I have a listbox (of product names) control on my form. I want to pass
the selected item (a product name) to a subform, and the product unitprice
should apear automatically next to the product name in the subform. Is
it possible? How do I do this? Thanks in advance.
"MGFoster" <me@privacy.com>
??????:QX***************@newsread1.news.pas.earthl ink.net... -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I'd set up the ListBox's RowSource property to return both the product
name and it's price. Hide the Price by setting its column width to
zero. The RowSource SQL would look something like this:
SELECT ProductName, Price FROM Products
The ListBox's ColumnWidths would be something like this:
Column Widths: 1.5";0"
Zero indicates the Price will not show in the ListBox.
I used inches (") - change to whatever metric you normally use.
The following assumes the ListBox is not a multi-select list box (IOW,
only one item can be selected at a time). In the subform controls, pull
the data from the ListBox like this:
ProductName:
The product name is in column zero (1st column in SELECT clause)
ControlSource: =Parent!ListBoxName.Column(0)
Price:
The price is in column 1 (2nd column in SELECT clause)
ControlSource: = Parent!ListBoxName.Column(1)
See the Access Help articles on "Parent" and the Column property of the
List/Combo Box controls.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQUhrVYechKqOuFEgEQJl1wCfeZ+YYg57qs5xkrhcZ+u8X+ pxKJoAn0HY
Q+K0OgrXNsOhU1ms+wTjA1e7
=T/DR
-----END PGP SIGNATURE-----
Paul T. Rong wrote:
I have a listbox (of product names) control on my form. I want to pass
the selected item (a product name) to a subform, and the product unitprice
should apear automatically next to the product name in the subform. Is
it possible? How do I do this? Thanks in advance.