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

Want Multiple Fields In ComboBox's DropDown List 1

Status
Not open for further replies.

drosenkranz

Programmer
Sep 13, 2000
360
US
Hi,

I'm using VFP 7.0 (SP1) on a Win '98 machine. Here's my problem.

Each person in a family is assigned an IDNum in the Household Member's table (grid) on a pageframe. I have a grid on another page of the pageframe where the household member's Incomes are entered. Since the user may not remember each person's IDNum in a household, I want to make the combobox on the Incomes page display more than just the IDNum field.

On the Incomes page, I want the combobox to display thehousehold member'd ID# followed by their name - but I want the controlsource to be (to store) only the household member's IDNum for each entry in the Income table.

Can a combobox display more than one field AND still have its controlsource save only the first field (IDNum) after a user selects from the combobox's dropdown list?

Thanks,

Dave

Example: Allt(str(IDNum)) + allt(lname) + ", " + allt(fname)

The 2nd mouse gets the cheese.
 
in the init event of the combo box:

this.Rowsourcetype = 3 && sql
this.rowsource = 'Sele IDNum,Name from YourTable where YourCondition order by IdNum into cursor cmbCursor'



Ali Koumaiha
TeknoSoft Inc
Farmington Hills, Michigan
 
Yes, there are many ways to do this. You'll want to study up on the following properties of the combobox:

BoundColumn
BoundTo
ColumnWidths
RowSource
RowSourceType

...BoundColumn and BoundTo are really the pertinent properties to accomplish what you are trying to do (although the others play a significant roll and is why I included them). If you click on each of those properties you will see a brief description of what each one does in the bottom of the property sheet, and the VFP Help File will give you some additional information. What you are asking for is a very common need for a combobox, so it is a very valid question. If you still can't get it after working with those properties, post back here the name of the RowSource you want to use, the RowSourceType and the name of the pertinent fields such as Name and IDNum or whatever. Then myself or another member can give you the exact solution.

Slighthaze = NULL
craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
Hi,

Can't get this to work either way. Need a combobox showing ID's and the name.

Table has three fields: idnum as Integer, nameof as Char, and inuse as Logical

Using just the table, I set a filter for inuse = .T. and I get all of the idnum(s) that are in use in the combobox - but no name next to the idnum value in the box.


Creating a SQL statement using:
SELECT * FROM local_used_ids WHERE inuse = .T. ;
ORDER BY idnum INTO CURSOR gcur_hhmemsid_sql

RowSourceType = 3 && SQL
RowSource =idnum && (field within cursor?)

I'm running the Select SQL statement in my main program and again in the Page's Activate Event so when the user opens this page in the pageframe, it has the latest info.

Any suggestions would be appreciated

Dave

The 2nd mouse gets the cheese.
 
Dave,

First, when you say you 'set the filter for in-use = .T.', do you mean you have a VFP SET FILTER command? Or are you referring to the WHERE clause of your SELECT? The latter is good, the former is not.

Next, you seem to be creating a cursor for the combo, but then setting the RowsourceType to 3, which suggests that you need to put your SELECT statement directly into the RowSourece property. You can't have it both ways.

I'd suggest you do something like this:

THIS.RowsSourceType = 3
THIS.RowSource = ;
"SELECT lName, IDNum FROM local_used_ids WHERE inuse = .T. ORDER BY idnum "
THIS.ColumnCount = 2
THIS.ControlSource = <field in main table that you want to bind to ID number, if any>
THIS.BoundColumn = 2

All of that should go in the Init of the combo. The lname will appear first (and also in the closed portion of the combo), but the ID will be bound to the main table. If you want to hide the ID from the user, use ColumnWidths to set the width of the second column to 0.

Mike


Mike Lewis
Edinburgh, Scotland
 
Oooops... think I found it.

The 2nd mouse gets the cheese.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top