Solved

DBLookupCombox (Sorting)

Posted on 2000-03-16
7
233 Views
Last Modified: 2010-04-04
History:

I use a Dbtext component to create the Rqst_ID (which is autoincrement field)for example 18. I copy TNG-0- string into the Doc_id Dbtext component plus the Rqst_ID which gives me TNG-0-18.

The problem I am having is in the dblookupcomboxbox component, the Doc_Id is display like this below.


TNG-0-18
TNG-0-181
TNG-0-19
TNG-0-190
TNG-0-191

Is there a way I can sort in this order instead.

TNG-0-18
TNG-0-19
TNG-0-181
TNG-0-190
TNG-0-191

If this is not enough points let me know.

Thanks alot,

Angela
0
Comment
Question by:Angela030399
7 Comments
 
LVL 5

Accepted Solution

by:
TheNeil earned 100 total points
ID: 2623971
No idea if this will work or not but you might have to copy the items from your DBLookupComboBox into a regular ComboBox and do the sort manually. There's no sort setting to specify HOW the items are sorted (it uses alphabetical) so I think you're going to have to do things manually (regardless of if you copy it to another combobox or if you can use the DBComboLookupBox). Alternatively if you can pad your Rqst_ID values with 0's then it'll do the job for you

e.g.

TNG-0-018
TNG-0-019
TNG-0-181
TNG-0-190
TNG-0-191

The Neil
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2624202
I think you have to sort it at the source. Fill the DBLookupComboBox by using a query that produres a result in the right order:

Select * from table order by somefield;
0
 

Expert Comment

by:Iamme
ID: 2624721
ok...you colud change the data tyoe of the fiel,,bacause ORDER BY.only sort by ord(q)....................and if you want to sort by number.........you should change data type to NUMBER...............

select * from table order by somefield;

It coul function if the fiels was an integere value
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Expert Comment

by:Epsylon
ID: 2624850
>It coul function if the fiels was an integere value

Not true! How told you that?
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2624868
I mean you can sort on all types except blob and similar fields.
0
 

Expert Comment

by:evansj
ID: 2625721
Here's the way I do it:
Drop a regular combobox instead. Add Table component and datasource hooked to the table component.
At design time set sorted property to true.
Programmatically( you may want to add this in the Form.Create event handler):
table1.active:=false;
table1.tablename:=<tablename>;
table1.disablecontrols;
table1.open;
table1.first;
while not table1.eof do
begin
combobox1.items.add(
table1.fieldByName(<fieldname>).AsString);
table1.next
end;
table1.enablecontrols;

This will produce a sorted combo box of items.

I've messed with the dblookupcombo and like my way better.
0
 

Author Comment

by:Angela030399
ID: 2641148
Thanks The Neil,

I pad Rqst_ID values with 0's which was the easiest to do.

Thanks, Angela
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi XE10 Round Image 2 192
Performance of SQL statement 37 137
Tembedded WB animatid gifs not animated on some pcs 2 86
Adoquery sql  left join does not work 25 105
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question