473,499 Members | 1,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help! pass listbox item to a subform

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.

Paul from Slovakia
Nov 13 '05 #1
3 3586
If your subform is unbound (the subform is not using a Table or query as
its recordsource) and you have like a textbox control (or some other
control) then you might think about placing those controls on your main
form. The purpose of a subform is to display data from a table or query
in Datasheet View. The reason for this is because if you select
Datasheet View on the main form, you cannot see your other controls. So
you use a subform in Datasheet view, you place that on your main form as
just another control, along with other controls like a textbox, listbox,
etc.

As for getting data from a listbox:

Text1 = List1.Column(0) 'if you have a one column listbox

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #2
-----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.


Nov 13 '05 #3
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.

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
6482
by: Dave | last post by:
After following Microsofts admonition to reformat my system before doing a final compilation of my app I got many warnings/errors upon compiling an rtf file created in word. I used the Help...
4
3319
by: Sarir Khamsi | last post by:
Is there a way to get help the way you get it from the Python interpreter (eg, 'help(dir)' gives help on the 'dir' command) in the module cmd.Cmd? I know how to add commands and help text to...
2
6371
by: Sudheer Kareem | last post by:
Dear All Please tell me how to assosiate help files with my Vb.net Project. Regards Sudheer
6
4298
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
6
2982
by: d.warnermurray | last post by:
I am doing a project for school that involves creating help files for a html authoring tool. If you could help me with answers to some questions it would really help. 1. What tasks do you expect...
2
3924
by: BT Openworld | last post by:
I have just had to upgrade to Access 2003 as Access 97 EMail (SendObject) doesn't work when loaded on Windows XP. I'm finding my way around Access 2003 but my biggest problem is getting...
7
5340
by: Corepaul | last post by:
Missing Help Files When I enter "recordset" as the keyword and search the Visual Basic Help index, I get many topics of interest in the resulting list. But there isn't any information available...
5
3247
by: Steve | last post by:
I have written a help file (chm) for a DLL and referenced it using Help.ShowHelp My expectation is that a developer using my DLL would be able to access this help file during his development time...
10
3326
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably...
1
6110
by: trunxnirvana007 | last post by:
'UPGRADE_WARNING: Array has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' 'UPGRADE_WARNING: Couldn't resolve...
0
7009
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7178
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7223
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4602
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3103
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3094
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.