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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate combo box from table?

Status
Not open for further replies.

sdmi

Programmer
Dec 6, 2001
17
US
I have table with two fields in it. I need to populate combo box with data from one of those fields. Can be done through properties window or command line? Tnank you.
 
You could use the AddItem method

USE YourDataFile
Do while !eof() && or whatever condition you want
Thisform.Combo1.AddItem(cFieldData)
Enddo


Tekno!

This is one way of doing it!
 
set the rowsource type to SQL

set the rowsource to

'select myfield from mytable into cursor whatever'

you need the into cursor or the browse window will pop up.

As to the above suggestion, if you want to do it that way
use a scan / endscan loop they are about 1000 times faster that a do enddo with an eof() check.

 
You can also set the rowsource property to the name of the field and table/cursor.

In the Init event of your form:

ThisForm.Combo1.rowsourcetype = 6 && Fields
ThisForm.Combo1.rowsource = myField.myTable

or use the builder -- right click on the object and select builder.

Or in the properties window -- set the rowsource and rowsource type to the appropriate values.

In the init event of the form you can also filter the data.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top