This is a multi-part message in MIME format.
------=_NextPart_000_004F_01C4D92C.9210F5F0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi Jeremy,
In your application, as you just need to diaplay the price,a label or a =
diabled text box would be a better option than a listbox.I'm sending you =
a snippet of code to load a list box and display corresponding =
details.You can use the same logic to check the condition for the item =
in second listbox
Dim ocmd As New OleDb.OleDbCommand
Dim strcon As String
Dim oDR As OleDb.OleDbDataReader
strcon =3D "Provider =3D Microsoft.Jet.OLEDB.4.0;Data =
Source=3DC:\db3.mdb;Persist Security Info=3DFalse"
ocmd.Connection =3D New OleDb.OleDbConnection(strcon)
ocmd.Connection.Open()
ocmd.CommandText =3D "Select CompanyName from Customers"
oDR =3D ocmd.ExecuteReader(CommandBehavior.SequentialAccess)
Do While oDR.Read
ListBox1.Items.Add(oDR.Item("CompanyName"))
Loop
If oDR.Read() Then
With oDR
txtCompName.Text =3D .Item("CompanyName").ToString()
txtContact.Text =3D _
..Item("ContactName").ToString()
txtDate.Text =3D _
..Item("BirthDate").ToString()
txtAddress.Text =3D _
..Item("Address").ToString()
End With
End If
oDR.Close()
'oCmd.Connection.Close()
HTH
Mona
[quoted text, click to view] "Jeremy Dillinger" <jerdill@hotmail.com> wrote in message =
news:u9jBZhP2EHA.804@TK2MSFTNGP12.phx.gbl...
> I have a program setup to pull data from a database. My database table =
has
> things such as (category, Item, price, etc.) In my program I want to =
have
> multiple list boxes that will have a pull down list of different =
categories.
>=20
> The category is stored as a number and the item is stored as a string. =
Also
> once the item is picked from the list I would also like to extract the =
price
> corresponding to the chosen item. How would I go about doing something =
like
> this. Thanks for your help!
>=20
> Jeremy
>=20
>
------=_NextPart_000_004F_01C4D92C.9210F5F0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1476" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Hi Jeremy,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>In your application, as you just need =
to diaplay=20
the price,a label or a diabled text box would be a better option than a=20
listbox.I'm sending you a snippet of code to load a list box and display =
corresponding details.You can use the same logic to check the condition =
for the=20
item in second listbox</FONT></DIV>
<DIV>
<P><FONT face=3DArial size=3D2>Dim ocmd As New =
OleDb.OleDbCommand</FONT></P>
<P><FONT face=3DArial size=3D2>Dim strcon As String</FONT></P>
<P><FONT face=3DArial size=3D2>Dim oDR As =
OleDb.OleDbDataReader</FONT></P></DIV>
<DIV>
<P><FONT face=3DArial size=3D2>strcon =3D "Provider =3D =
Microsoft.Jet.OLEDB.4.0;Data=20
Source=3DC:\db3.mdb;Persist Security Info=3DFalse"</FONT></P>
<P><FONT face=3DArial size=3D2>ocmd.Connection =3D New=20
OleDb.OleDbConnection(strcon)</FONT></P>
<P><FONT face=3DArial size=3D2>ocmd.Connection.Open()</FONT></P>
<P><FONT face=3DArial size=3D2>ocmd.CommandText =3D "Select CompanyName =
from=20
Customers"</FONT></P>
<P><FONT face=3DArial size=3D2>oDR =3D=20
ocmd.ExecuteReader(CommandBehavior.SequentialAccess)</FONT></P>
<P><FONT face=3DArial size=3D2>Do While oDR.Read</FONT></P>
<P><FONT face=3DArial=20
size=3D2>ListBox1.Items.Add(oDR.Item("CompanyName"))</FONT></P>
<P><FONT face=3DArial size=3D2>Loop</FONT></P>
<P><FONT face=3DArial size=3D2></FONT> </P>
<P><FONT face=3DArial size=3D2>If oDR.Read() Then</FONT></P>
<P><FONT face=3DArial size=3D2>With oDR</FONT></P>
<P><FONT face=3DArial size=3D2>txtCompName.Text =3D=20
..Item("CompanyName").ToString()</FONT></P>
<P><FONT face=3DArial size=3D2>txtContact.Text =3D _</FONT></P>
<P><FONT face=3DArial =
size=3D2>.Item("ContactName").ToString()</FONT></P>
<P><FONT face=3DArial size=3D2>txtDate.Text =3D _</FONT></P>
<P><FONT face=3DArial size=3D2>.Item("BirthDate").ToString()</FONT></P>
<P><FONT face=3DArial size=3D2>txtAddress.Text =3D _</FONT></P>
<P><FONT face=3DArial size=3D2>.Item("Address").ToString()</FONT></P>
<P><FONT face=3DArial size=3D2>End With</FONT></P>
<P><FONT face=3DArial size=3D2>End If</FONT></P>
<P><FONT face=3DArial size=3D2>oDR.Close()</FONT></P>
<P><FONT face=3DArial size=3D2>'oCmd.Connection.Close()</FONT></P>
<P><FONT face=3DArial size=3D2>HTH</FONT></P>
<P><FONT face=3DArial size=3D2>Mona</FONT></P></DIV>
<DIV><FONT face=3DArial size=3D2>"Jeremy Dillinger" <</FONT><A=20
href=3D"mailto:jerdill@hotmail.com"><FONT face=3DArial=20
size=3D2>jerdill@hotmail.com</FONT></A><FONT face=3DArial size=3D2>> =
wrote in=20
message </FONT><A =
href=3D"news:u9jBZhP2EHA.804@TK2MSFTNGP12.phx.gbl"><FONT=20
face=3DArial =
size=3D2>news:u9jBZhP2EHA.804@TK2MSFTNGP12.phx.gbl</FONT></A><FONT=20
face=3DArial size=3D2>...</FONT></DIV><FONT face=3DArial size=3D2>> I =
have a program=20
setup to pull data from a database. My database table has<BR>> things =
such as=20
(category, Item, price, etc.) In my program I want to have<BR>> =
multiple list=20
boxes that will have a pull down list of different categories.<BR>> =
<BR>>=20
The category is stored as a number and the item is stored as a string.=20
Also<BR>> once the item is picked from the list I would also like to =
extract=20
the price<BR>> corresponding to the chosen item. How would I go about =
doing=20
something like<BR>> this. Thanks for your help!<BR>> <BR>>=20
Jeremy<BR>> <BR>> </FONT></BODY></HTML>
------=_NextPart_000_004F_01C4D92C.9210F5F0--