954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Add Data from Access to Combo Box

please help that how to add data of one field of database to the combo box.

i attached one rar file with this. check that

pranavdv
Light Poster
26 posts since Mar 2007
Reputation Points: 8
Solved Threads: 0
 
lostandfound
Junior Poster in Training
51 posts since Jan 2008
Reputation Points: 20
Solved Threads: 1
 

hi pranavdv...
where is your attachment?
Rar file is not supported in this forum, use zip file.

november_pooh
Junior Poster
121 posts since Mar 2008
Reputation Points: 29
Solved Threads: 0
 

try this code :

Private Sub Form_Load()
Dim RS As ADODB.Recordset
    Dim Conn As ADODB.Connection
    Dim Comm As ADODB.Command
    Dim str As String
    
    Set Conn = New ADODB.Connection
    Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = D:\Only Me\Authors.mdb"
    Conn.Open
    Set Comm = New ADODB.Command
    Set Comm.ActiveConnection = Conn
    Comm.CommandText = "SELECT Au_ID FROM Authors"
    Comm.CommandType = adCmdText
    Set RS = Comm.Execute
    
    Do Until RS.EOF = True
        Combo1.AddItem RS!Au_ID
    RS.MoveNext
    Loop
     
    Set RS = Nothing
    Set Comm = Nothing
    Set Conn = Nothing
End Sub
Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 

Thanks JX_MAN, I will take that as a compliment. I wonder how many of those solved threads of yours are down to blatantly copying other members replies.
Whereas copying obviously works for some , others benefit from doing a little bit of thinking themselves!!
Hope the code helps with your problem Pranavdv.
Getting to grips with the ADO control is hard work but is a great tool once you get rolling.
Cheers for now

lostandfound
Junior Poster in Training
51 posts since Jan 2008
Reputation Points: 20
Solved Threads: 1
 

??
hmm...sorry if this code some like yours...
well, i have a book for this.

Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You