Re: Selecting a data row (register ) with Listbox or Combo



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
---------------------------------------------------------


.



Relevant Pages

  • A VB6 program to generate CONSTants for a user defined gradient
    ... EndProperty ... It may be used for amy moral purpose. ... Dim mGreen1 As Long ... Private Sub ColorDisplay_MouseDown(Button As Integer, Shift As Integer, _ ...
    (comp.lang.basic.visual.misc)
  • Re: access 2003
    ... Dim ctl As Control ... Dim rs As Recordset ... This sets the query definitions for choosing data to create an invoice using ... Event on combo box: Private Sub ChooseCust_AfterUpdate ...
    (microsoft.public.access.conversion)
  • Re: Gradient Generator BMP Tool Improved
    ... EndProperty ... It may be used for amy moral purpose. ... Dim mGreen1 As Long ... Private Sub ColorDisplay_MouseDown(Button As Integer, Shift As Integer, _ ...
    (comp.lang.basic.visual.misc)
  • Multiple Calendar Control on one page
    ... Protected WithEvents Calendar1 As System.Web.UI.WebControls.Calendar ... Private Sub Page_Init(ByVal sender As System.Object, ... Dim mo As String ...
    (microsoft.public.inetserver.asp.components)
  • Calendar Control issue.
    ... Protected WithEvents Calendar1 As System.Web.UI.WebControls.Calendar ... Private Sub Page_Init(ByVal sender As System.Object, ... Dim mo As String ...
    (microsoft.public.dotnet.framework.aspnet)