SetRange() on multifield indexes.

Posted on 1998-06-30
Last Modified: 2010-05-18
Hello there,

I've created index for few fields. I'm willing to apple range for my table, and seems I can not do that.
For example I've two fields: Symbol and Number. I've created index for these fields. TotalIndex.
Now, I'm trying something like this:

  with Table1 do
    IndexName := 'TotalIndex';
    SetRange(['a', 1],  ['m', 10]);

I'm expecting to see all records with Symbol's value between 'a' and 'm' and
and Number's value between 1 and 10 but nothing happens. At all.
When I create separate indexes for each co;umn and write for example:

  with table1 do
    IndexName := 'NumIndex';
    FieldByName('Number').AsInteger := 1;
    FieldByName('Number').AsInteger := 10;

I see just what I expected to see. But I want to use one index for all fields. Possible? How?
Question by:_art_

Expert Comment

ID: 1356648
You didn't set the range properly. This range shows symbols between 'a' and 'm' that also have numbers between 1 and 10. If you want to see both then you should use Filter instead of Range:

 with table1 do
     Filter:='SYMBOL<='+Chr(39)+'m'+Chr(39)+' AND                 SYMBOL>='+Chr(39)+'a'+Chr(39)+' OR NUMBER<=10 AND NUMBER>=1';


Author Comment

ID: 1356649

Exactly what I need! I wanna see  records whose symbols between 'a' and 'm' and from them those where numbers between 1 and 10. Not both cases separate..
I know filters still would be the right suggestion but at some reasons I'd prefer not to use them.

Expert Comment

ID: 1356650
Hi _art_,

Why don't you want to use Filters?

Well, maybe this is possible :

 1. Take two tables, one master other detail.
 2. Filter the master table with a to m
 3. Filter the slave with 1 to 10

Never tried it, don't even know if it will work, but you can try it.

Regards, ZiF.

Accepted Solution

vladika earned 100 total points
ID: 1356651
I think with SetRange it's impossible.
Let Table have such date
a                     -1
a                      1
b                     -5
b                    10
m                    -1
m                   11
z                     0

I ordered it according to index.

SetRange(['a', 1],  ['m', 10]) set TWO BOUNDARIES (and ONE range) in ordered table.
First boundary between ('a',-1) and ('a',1).
Second boundary between ('m',-1') and ('m',11)
So you can see ('b',-5), ('m',-1) etc

You want set many ranges. It's impossible with SetRange


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Filemaker 14 vs Delphi Embarcadero 7 186
Delphi XE10, MySQL Query 4 126
Best Firemonkey component pack 1 87
Downloading email attachments 2 67
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

16 Experts available now in Live!

Get 1:1 Help Now