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

Create dropdown list with data from database file 3

Status
Not open for further replies.

rresendez

Programmer
Mar 14, 2005
40
0
0
US
I need to let the user choose a user from a dropdown list using the database file. Otherwords, I will have a database with all users in it and when I assign something to them, I want to be able to click on an arrow that shows a dropdown list with all the users listed. So when I highlight the name I want, it will choose that name.

Thanks,
Ramon
 
Thanks for the quick submittion Geoff, but I have no clue on what you mean. I have never used a combo box or know how to use RowSourceType. Would "2-Alias" be replaced with the database name or is that the exact setting? Is there a limit on how many choices can be listed? Any suggestions would be very helpful.

Thanks,
Ramon
 
Hi Ramón

Let's go step by step.

1. In your form select DataEnvironment and add the users table.

2. Add a ComboBox object to the form.

3. Select the properties and set RowSourceType set "2-Alias" and RowSource set to the name of the table (users); then set the Bound Column to the number of the field (or column) you want to store in the Value property. You can also set the Column Count (how many fields) an Column Widths.

Best regards,

Germán Restrepo
Bogotá, Colombia
 
Thanks Germancho,

Now what if there was a new user, could it be added at that time? Can there be more than one combo box in form?

Ramon
 
Yes, there can be more than one Combo in a form. When you add a new user you can use THISFORM.YourCombo.Requery() to update it and see the new ones.

Germán Restrepo
Bogotá, Colombia
 
Thanks again Germancho

You are talking over my head again. I have no idea what THISFORM.YourCombo.Requery() is. I aready have it where you can add users, but I was thinking that maybe at some point when they go to use it, if there is a name that wasn't added yet, can be added to the list instead of having to go to the portion where you add the users.

Ramon
 
Don't worry Ramón.

You can not add users directly from the combo because the users table has more than just one field; probably you have userid, name, etc and only one of them is stored in the Value property. You have a form where you add users, don't you?

The method Requery is used to refresh the data of the ComboBox.

Ramón, is spanish your native language? sometimes it's difficult to me found the correct words to explain what I want to say. I apologize for that.






Germán Restrepo
Bogotá, Colombia
 
I understand everything that you are saying. Thanks for all of your help. Yes, I am native of Mexico, but am in US and want to use English most of the time.

Thanks again,
Ramon
 
Can any of this be done outside of a form? What if I wanted to write it in the program myself? Any ideas out there?

Thanks,
Ramon
 
Can any of this be done outside of a form?

It is possible to put a combo box onto the VFP screen itself but you are also going to want a button for "Select User" and another for "Cancel" so the user will be happier to see these three together on a form - perhaps with a caption saying "Please select user"

Geoff Franklin
 
Thanks for the info Germancho. Where can I find out more about combo boxes, Especially about using it outside of a form?

Ramon
 
Thanks for your info also Geoff. Your info was also very helpful. I will be giving a star to both of you.

Ramon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top