Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to display data in combo box ?

Status
Not open for further replies.

cyberdyne

Programmer
May 1, 2001
173
IN
Hello !

I have a problem in my program.
I want to display all the names available in an Access2000 tabel viz. customer_master ( cust_id, cust_Name) into a combo box. I have used ado connection as

Dim cn As New adodb.Connection
cn.Open "provider=microsoft.jet.oledb.4.0.;data source=c:\gangaram\gangaram.mdb"
End Sub

I have used ado data control 6.0 (OLEDB).
In it's recordset property in sql command box i have given command as select * from customer_master.

When i run the program i am getting only first name in combo box. nothing else.

what do i do ?

Please help asap.

Thanx in advance.
 
again ! I would like data seen in the combobox sorted. This is text that will be displayed. Customr name.
 
hi,
Try this

Dim cRS As New ADODB.Recordset
Dim cSQL As String

cRS.CursorLocation = adUseClient
cSQL = "Select * From Customer_master Order By Customername "
cRS.Open cSQL, DSN, adOpenDynamic, adLockOptimistic

cbo.Clear
Do While Not cRS.EOF
cbo.AddItem crs.fields("Customer_Name")
cRS.MoveNext
Loop
cRS.Close


 
Make sure for you combo box that you're using the OLEDB control (it'll have "OLEDB" at the end of the component name). For instance, you would want to use "Microsoft DataList Controls 6.0 (SP3)(OLEDB)" rather than "Microsoft Data Bound List Controls 6.0"

Make sure you're using the correct properties. To fill the combo with the cust_Name field, set the RowSource property to your datacontrol and set the ListField property to cust_name. This will fill the combo box will all cust_name values in your table pointed to by the data control.

For sorting, just make sure you have the ORDER BY clause the way you want it in your SELECT statement.
 
Set it's ListField property to the field you want shown [/b][/i][/u][sub]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top