How can i put thevalue in combobox direct from MSAccess?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • daffurankan
    New Member
    • Apr 2007
    • 30

    How can i put thevalue in combobox direct from MSAccess?

    hai,
    iam ankan
    i am facing a problem my problem is
    i wanted that in visual basic 6.o i haddesign a form and ther is a combobox in it and i wanted that when i run the application the items in combobox1
    should pick directly from the database which is Designed in MS Access
    urgent reply me a soon
    orASAP.


    act soon urgent reply me .
  • fplesco
    New Member
    • Jul 2007
    • 82

    #2
    Originally posted by daffurankan
    hai,
    iam ankan
    i am facing a problem my problem is
    i wanted that in visual basic 6.o i haddesign a form and ther is a combobox in it and i wanted that when i run the application the items in combobox1
    should pick directly from the database which is Designed in MS Access
    urgent reply me a soon
    orASAP.


    act soon urgent reply me .
    Hey -

    Code:
    Dim Con As Connection
    Dim Rs As Recordset
    
    Public Sub PopulateCombobox()
    Set Con = New Connection
        Con.Open ""              'Connectionstring here
        Set Rs = New Recordset
        Rs.ActiveConnection = Con
        Rs.Open "Select * from EmpTable", Con, adOpenKeyset, adLockOptimistic
        If Rs.EOF Then
            Do Until Rs.EOF
                 combo1.addItem Rs!<fieldname>
            Loop
        End If
    End Sub

    Comment

    Working...