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!

Combo Column bound to numeric field value

Status
Not open for further replies.

csr

Programmer
Jul 20, 2000
507
I have been down this road before somewhere but cannot find anything about it by searching so I will ask again.

I have a combobox with the 2nd column bound to a numeric field value. This does not work.

The second column of the combobox is actually a numeric value but the combobox changes it to a character type value. Then it doesn't remember that it did that and chokes when it tries to put that character value into the numeric field.

Any simple means of dealing with this or do I have to build some sort of fancy array system or something to deal with it ?



Don


 
One of the things I am considering, as I wait ...

Is to re-write my framework so that it creates character type primary keys instead of numeric.

Any thoughts on that plan ?



Don


 
Whoops ... I apologize for being so incomplete with my message here.

The reason primary keys has come into this thread is because it is the value of a primary key that is being utilized in the combobox control and is being inserted into a numeric field.

So, I thought maybe I will save myself a ton of problems in the future by just making my primary keys CHARACTER TYPES.

Your thoughts are appreciated.


Don


 
Don,
When using a "bound" numeric value on a combobox, you need to make sure you set BoundTo to .T.

Check back if that doesn't fix things.

Rick
 
Yep, that worked.

Reading the description of the BoundTo property ....

It says something about assigning the value to the List property or the List Index property.

Can you explain the difference ?



Don


 
OK Don,
If the bound column is numeric, and BoundTo is .F. (Default), then instead of the value being "returned", the ListIndex value is returned. The ListIndex is normally the relative order of the Item in the list. i.e. The first member has a value of 1, the second has a value of 2, etc. (This can be different if you add and then delete items using the AddItem() method and RemoveItem() method - <s>!)

If the bound column is numeric, and BoundTo is .T., then the value of the bound column item is "returned". This is also refered to as the List Property.

Rick
 
Very good. And ... I assume ... if the bound column is a character type, the value is returned regardless of the BoundTo setting ?


Don


 
Don,
Correct - there is no confusion with character data, just numbers!

Rick
 
I am wondering why there is confusion with numeric values if there is none with character values.

Why couldn't I wish to have the index returned even though the bound column is of type character ?

I guess what I am looking for is an example of when I would wish to return the INDEX with a bound column that is numeric. And, then try to understand why that situation would never arise with a character bound field.



Don


 
Don,
It's difficult to explain "why" when MS has never really given an explanation. The combobox is really 5 or 6 different controls rolled into one, and there were obviously some compromises made. The reason was to make it backward compatible with the old FP DOS and FP Windows (3.x) code, and still follow the Windows 32 GUI standards.

I'm just glad that with a little tweaking, I can make the same control use data from arrays, cursors (including tables and views), queries, add my own data directly (I believe that's the only way the .NET combobox works) and even use it to provide a compact file selection!

Rick
 
Ok ... we will go with that ... Thanks


Don


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top