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

How to fill in a combo box with data from a table

Status
Not open for further replies.

arc42

Programmer
Sep 18, 2012
9
PH
I want to put data from a table in the combo box on my form.
How can I do that?

 
There are, inevitably, a number of ways.

I quite like using a select statement, you set the rowsourcetype to "3 - SQL Statement"
and the use something like this for the RowSource

Code:
SELECT NAMEREF,FULLNAME(TITLE,FORENAME,SURNAME) FROM FCTUSER WHERE SIGNATORY ORDER BY NAMEREF INTO CURSOR CFCTAUTH

I've deliberately chosen a somewhat cumbersome select statement so you can see how flexible it can be, in the example I have used a UDF
to build an otherwise non-existant 'fullname'

A simpler example might be:

Code:
SELECT CODE, DESCRIP FROM MYTABLE ORDER BY CODE INTO CURSOR TMPTABLE

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Thanks Griff! But it does'nt work in my form..
I have a table: tbl_status
with fields: statno, astatus
I put records in it and when I run my form, there were no items appeared in the combo box..
 
Did you set the rowsourcetype and rowsource

I think for you it would be...
Code:
select statno,astatus from tbl_status order by statno into cursor tmpStatus

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
oh...I'm sorry, I forgot it...
Thank you so much! It works..
Hope you could help me more in some of my vfp problems...Thank you very much!
 
No problem

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top