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!

Help with Retreiving Data..???

Status
Not open for further replies.

inkfid

Technical User
Nov 18, 2004
14
GB
I have an app that adds/removes Companys and their Locations as two seperate fields in a table.

What I want to do when my app loads is fill a combo box with each company name once, regardless of how many times it appears in the data base.

I am using vb6 and MS Access.
 
Use a recordset like
Code:
Dim rs As DAO.Recordset
Set rs = db.OpenRecordset( _
   "Select DISTINCT [Company Name] From myTable")
cboCompany.Clear
Do Until rs.EOF
   cboCompany.AddItem rs![Company Name]
   rs.Movenext
Loop
Set rs = Nothing
If the combo is a bound control then use that SQL statement in it's recordsource.
 
Awesome!! thank you. Feel a little bit stupid now i now all I needed to add was the word distinct!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top