Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Converting Integer to String for LookUp control
Tue, Sep 2 2008 4:48 AMPermanent Link

Pat
Hi all,

I use the Woll2Woll dbLookupCombo contol - I like the Quicken stlye
AutoComplete feature. The AutoComplete works fine on string indexes.

This time I have an integer index field and the AutoComplete does not
work as such.

Question is: how would you go getting a string field from the integer
field into a lookup table/SQL? I had thought using a query somehow
like

SELECT The-Integer, The-Integer-Converted-To-A-String
FROM MyTable
ORDER BY The-Integer-Converted-To-A-String

and then base the TwwDBLookupCombo on the query and use
The-Integer-Converted-To-A-String as the LookupField. Problem is I do
not know how to get the field The-Ineger-Converted-To-A-String in the
SLQ Frown

OR, is there a better way in doing this?

Thanks.

Regards,
Pat
Tue, Sep 2 2008 5:30 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Pat


Getting an integer field as a string is a piece of cake - just use CAST(field AS VARCHAR(x)) where x is the length of the field you want the integer to end up in.

Unfortunately your problem is more likely to be with the fact that numbers as characters do not sort "correctly" ie if you have 1,2,3,10 it will sort 1,10,2,3


Your query would need to be

SELECT The-Integer, CAST(The-Integer AS VARCHAR(10))
FROM MyTable
ORDER BY The-Integer

That would give you a correctly sorted result set but how the autocomplete feature would work I have no idea since I don't have the w2w controls

Roy Lambert [Team Elevate]
Tue, Sep 2 2008 8:59 AMPermanent Link

Pat
Hi Roy,

>just use CAST(field AS VARCHAR(x)) where x is the length of the field you want the integer to end up in.

that worked perfect   Smile

Many thanks.

Regards,
Pat
Image