Go Back   Forum Care Forums > Development Reference Area > Visual Basic

Reply
 
LinkBack Thread Tools Display Modes
How to use combo box with adodc to retrive field in access database.
Old
  (#1)
Smith_X
Guest
 
Posts: n/a
Default How to use combo box with adodc to retrive field in access database. - 06-04-2007, 08:56 AM

I have access database which I willuse form to retrieve a field to
show in List of combo box.

the method that I use now is adodb code when form load is show below.

Private Sub Form_Load()
Dim sql As String
Dim i As Integer

StrConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path &
"\master.mdb;Persist Security Info=False"

With Cn
If .State = adStateOpen Then .Close
.ConnectionString = StrConn
.ConnectionTimeout = 90
.CursorLocation = adUseClient
.Open
End With

sql = "SELECT * FROM Room"
Rs.Open sql, Cn, adOpenDynamic, adLockOptimistic, adCmdText

' in this section, I will load the CustomerID to show in this form in
combo box.
cboCustomerID.Clear
For i = 1 To Rs.EOF
cboCustomerID.AddItem !rs.("customerid")

Next
' but it's still not work yet.
' the code below is not work anyway.. I'm still confuse the exactly
way to coding..
' With Rs
' Do Until .EOF
' cboCustomerID.AddItem !roomid
' .MoveNext
' Loop
' End With

Call DisplayData 'this is an sub routine that will retrieve data from
field in database to show in textbox in my form. the most coding in
this section is txtroomid = rs("roomid")
.....
End Sub

please help me, I really want to show data in combo box
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top