Re: Selecting a data row (register ) with Listbox or Combo
- From: "Raj Kasi [MSFT]" <lkasi@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 29 Sep 2005 15:53:38 -0700
I will try to provide a simple example below.
=======================================================
Private Sub Combo1_Click()
Text1.Text = Combo1.Text
End Sub
Private Sub Form_Load()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim cmd As New ADODB.Command
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Testdb.mdb;"
cmd.ActiveConnection = cn
cmd.CommandText = "select * from SampleTbl"
Set rs = cmd.Execute
While Not rs.EOF
Combo1.AddItem (rs.Fields.Item(0).Value)
rs.MoveNext
Wend
Set rs = Nothing
Set cmd = Nothing
cn.Close
End Sub
=======================================================
Make sure you have a combo box and text box on the Form. Double click on the
Form and paste the above code.
As you can see from the example I am populating a recordset and looping
through it to populate the combo box. Once this is done, with one click you
can select the item you want from the combo box and the text box gets the
selection.
---------------------------------------------------------
This posting is provided "AS IS", with no
warranties, and confers no rights.Please
do not send email directly to this alias.
This alias is for newsgroup purposes only
---------------------------------------------------------
.
- Prev by Date: ADO connection question
- Next by Date: RE: Error in SQL Statement
- Previous by thread: ADO connection question
- Next by thread: Re: Problems querying DB2 through ADO
- Index(es):
Relevant Pages
|
|