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!

ComboBox help needed... 1

Status
Not open for further replies.

stanlyn

Programmer
Sep 3, 2003
945
US
Hi,

Using VFP9sp2 and the fixes, I've struggled for years for an elegant solution for combo boxes. The behavior I've used before works but is kluggy and way too many steps. Maybe someone can steer me toward an elegant solution. I suspect it to be a common usage use.

Lets say we have 2 tables, Invoices and PayTypes, where Invoices has a field that contains the pay type used for that particular invoice. The PayTypes table contains a list of available pay types such as visa, cash, net30, m/c and amex.

Now, on the Transaction data entry form I need the combobox's displayvalue to shows the value saved for that particular invoice. The displayvalue will change as you skip about the Invoice table's records.

Now, when clicking the combobox, it should show the list of available types populated from the PayTypes table with the saved Invoice's selection already selected, therefore by pressing enter it would not change anything, however if you select any other type in the list, the combo would close and save that selection to the Invoice and show it in the displayvalue.

To get this functionality, what pems and their settings is required. I've fought this on and off for years now and have really never found a proper and simple solution. Please be specific as possible...

Thanks,
Stanley
 
You have no foreign key in your case. If you wantr your database to be state of the art you change your invoice table to have a paytypeID foreign key and lookup the paytype name in the paytypes table this way.
If you want to stay your way, stay your way, but then you can't use the combobox to display paytype name in the invoice, then you'd go with a textbox, maybe autocomplete textbox.

Bye, Olaf.
 
Olaf,

>> what is displayed is determined by rowsource, not controlsource. Controlsource navigates to a record in rowsource

If this is true and I've never seen this explanation before, then that explains a lot. I need to test some more with this knowledge.

Where did you learn this from? My vfp9sp2 combobox docs says nothing like that. I'd be interested in seeing a combobox sample that illistrates this.

Thanks, Stanley

 
C'mon, you of course have to set BoundTo, BoundColumn and the Rowsource/RowsourceType in conjunction with this to work correctly. But then the Controlsource controls the combobox and is written to as with the textbox or listbox or other controls. That's its major purpose, isn't it?

You already starred my answer, or did someone else do?

Bye, Olaf.
 
One more thing: What is displayed int the combobox in its collapsed state always is column1 of rowsource. That's why I put the paytype name in there and made ID the second column.

Bye, Olaf.
 
Olaf, where are you getting this info? Would you mind sharing that reference?

Hang on until I test your suggestions...

Thanks, Stanley
 
I still use Foxpro professionally daily. Our customer still has in the range of 10 to 20 foxpro applications running. So when I don't learn from questions asks I learn from reading and experience.

In general the Rowsroucetype description says it's the source for the display. And then a simple test: Set ColumnCount 2 and ColumnWidth 100,100 and ColumnLines .T., then two columns are displayed in the items list in expanded state. But only one in collapsed state. Everything, that is written about multiple columns only holds true for the dropdown list. The collapsed state of the combobox is a textbox, and that displays one value. The first column of rowsource. It doesn't display the controlsource, because that typically is a foreign key, a surrogate key like a number or guid. It displays the selected item and what represents it better than a column of the rowsource?

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top