0

I want to populate combo box with particular field value of a table in ms access.

datafile = "D:\database.accdb"
With cn
.Provider = "microsoft.ACE.OLEDB.12.0"
.ConnectionString = datafile
End With
cn.Open
Set rs = cn.Execute("select * from mytable")

Do Until rs.EOF
combo1.AddItem rs!name
rs.MoveNext
Loop

cn.Close

I am getting runtime error 3705 provider of object connection failed

Edited by pritaeas: Added markdown.

2
Contributors
2
Replies
22
Views
3 Years
Discussion Span
Last Post by ponnu
Featured Replies
  • 1

    Try this : Private Sub Form_Load() Dim Conn As New ADODB.Connection Dim rs As ADODB.Recordset Set Conn = New ADODB.Connection Conn.Provider = "Microsoft.ACE.OLEDB.12.0" Conn.CursorLocation = adUseClient Conn.Open "D:\database.accdb" Set rs = New ADODB.Recordset rs.Open "select * from mytable", Conn, adOpenDynamic, adLockBatchOptimistic While Not rs.EOF Combo1.AddItem rs!name rs.MoveNext Wend rs.Close End … Read More

1

Try this :

Private Sub Form_Load()
    Dim Conn As New ADODB.Connection
    Dim rs As ADODB.Recordset

    Set Conn = New ADODB.Connection
    Conn.Provider = "Microsoft.ACE.OLEDB.12.0"
    Conn.CursorLocation = adUseClient
    Conn.Open "D:\database.accdb"

    Set rs = New ADODB.Recordset
    rs.Open "select * from mytable", Conn, adOpenDynamic, adLockBatchOptimistic

    While Not rs.EOF
        Combo1.AddItem rs!name
        rs.MoveNext
    Wend
    rs.Close

End Sub
Votes + Comments
nice..
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.