Management said:
I forgot to trim the table and the try to match with my values ?
I think you're on topic, but still in the inverse logic.
If you have char(n9 fields, they are char

, no matter if you trim values before storing them or not, they become char

with length n, padded, not trimmed.
And then because of that you also don't trim the values you search for.
Management said:
ALLTRIM(STR(ordernumber,7))+ordertype
And it just works
with seek ordernumber+ordertype
Well, well, not so fast.
Is ALLTRIM(STR(ordernumber,7))+ordertype what you tried before or what you got from ? KEY()
I'm not in your computer nor your mind,
![[dazed] [dazed] [dazed]](/data/assets/smilies/dazed.gif)
sorry.
If the index is on the simple expression (= KEY()) ordernumber+ordertype, then this is simple string concatenation of the fields. The
untrimmed data values stored in them.
SEEK ordernumber+ordertypeworks once you are on the record you seek you just stay there.
What still won't work is when you have 2 inputs 123 and ABC and just add them together.
Management said:
and re-run your command I get
>> 123456TYPEE<<
Now we're nearly there, Now I'd still need to know and not just guess which part comes from which field, I could have asked to look at the single fields themselves, too:
? '>>'+orderno+'<<'
? '>>'+ordertype'<<'
The index expression field1+field2 concatenates what's stored in the fields, not necessarily the trimmed values you initially only stored by INSERT or textbox controlsource. The values usually are padded to the right, when you have spaces in front, the values are stroed with spaces, that's not a result of automatic padding to the field length. And now finally, what value you need to seek, depends not only on the expression but also the field ddefinition including their lengths, because that plays a role in what ordernumber+ordertype becomes.
And here's something to feed your interest: What happens with an index when you ALTER a table and extend the field length? What stays the same?
How would all that play out if the index expression would be STR(orderno,5)+Substr(ordertype,5,1)? Would it be better to index that or not, would it make indexes more stable or not? Need code changes of current code SEEKing data? How would it impact LOCATE or SQL WHERE clauses? So what do you really need to be aware of too make good use of an index in VFP. NOte: In other databases you merely index fields as is, mayhave indexes that contain multiple fields. In VFP you always index an expression, even the single field name is an expression, the simplest expression but it's not just the field, it's an expression that has the field name.
So what happens if you take two tables SET RLEATION from table1 to table2, somehow (look up what that means), and INDX ON fieldx with fieldx being a field of table 2, while the index key becomes an index of table1?
Chriss