Solved

DBLookupCombox (Sorting)

Posted on 2000-03-16
7
230 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 13

Expert Comment

by:Epsylon
Comment Utility
>It coul function if the fiels was an integere value

Not true! How told you that?
0
 
LVL 13

Expert Comment

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

Expert Comment

by:evansj
Comment Utility
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
Comment Utility
Thanks The Neil,

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

Thanks, Angela
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now