Pop-up and DB filtering problem

I'm very near to close my project ( last step ). I feel how my brain blow up so I can't concentrate now to finish the job .

My final problem is to use a pop-up with ( for example ) 10 items and a Table .
What I need is :
when select an item to check him as selected ( if I choice another one this will be unchecked and the new selected one will be checked).

If one of next sample items is selected then the table must be filtered as I can see into a dbGrid just specified records .

1. First item ..... show just from first record to 23th record
2. Second item .....     from 24th to 50th
...........
10. Last item .....      from 125 to last record .

300 points for source codes .

Regards,
Nick

P.S. WHERE IS MY BED ? :P
LVL 9
ginsonicAsked:
Who is Participating?
 
ComTechConnect With a Mentor Commented:
Points were awarded on seperate question, as stated above, therefore this question will be placed in PAQ.

Regards,
ComTech
CS @ EE
0
 
jswebyCommented:
If your database supports the "SELECT TOP n" SQL statement, then you could use

SELECT TOP 25 * FROM mytable

for the first 25, then

SELECT TOP 25 * FROM mytable
WHERE id NOT IN (SELECT TOP 25 id FROM mytable)

for the next 25,

then

SELECT TOP 25 * FROM mytable
WHERE id NOT IN (SELECT TOP 50 id FROM mytable)

J.
0
 
kretzschmarCommented:
?  what about the moveby-method of tdataset
just an idea
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

 
jswebyCommented:
kretzschmar,
Yes, that was my first thought, but MoveBy simply moves the cursor position within the dataset doesn't it, it wouldn't filter the first x number of records out of the DBGrid.

J.
0
 
kretzschmarCommented:
well its a bit more than simple move 25 records records,
but your selects do not work for every database

personally i would cache the record-ids in a list in the order as i need and create a select stament on the fly with an in-clause for the display

meikl ;-)

0
 
DragonSlayerCommented:
what database are you using? If you are using mySQL, it has a LIMIT keyword, with the syntax LIMIT [offset,] rows]

e.g. you can have

SELECT * FROM myDatabase ORDER BY m_user_id LIMIT 10
to return the first 10 results, or

SELECT * FROM myDatabase ORDER BY m_user_id LIMIT 5, 10
to retrieve results from 6-15

but if you are using other DBMS.. umm... well, no expertise in that, sorry :)
0
 
ginsonicAuthor Commented:
Is a simple dbf (FOX) file .

How about pop-up part ?

For the second ( filtering ) I thinking to create a new field and record the pop-up item number for each case. If field value = 1 then ...

But I'm not sure that is a proffesional way :(
0
 
DragonSlayerCommented:
umm... what pop-ups?
0
 
ginsonicAuthor Commented:
A pop-up menu with 10 items . Depend of selected item menu I will filter the table .

And I need that the selected item to be checked and all others unchecked .
0
 
DragonSlayerCommented:
make it a radio button instead of a checkbox?
0
 
ginsonicAuthor Commented:
I think that you don't understand the problem . Isn't a checkbox in pop-up menu . Just the item is checked .

And I think that I found myself the solution :
I will use a variable stock. At start the first item is checked. Store stock:=1. When select another item uncheck item[stoc] and check new one and store stock:=newitem ....... blablabla .

0
 
ginsonicAuthor Commented:
How I say, I was very tired when I ask this and with the hope that I will get a fast solution here for my problem .
Thanks for support guys but I found allready the answer myself .

Thanks again and keep in touch :)
0
 
DragonSlayerCommented:
ginsonic, if it's a popupmenu, in each of your popupmenuitem, set the groupindex to a same number that is <> 0.

now, when any of the menuitems is checked, the rest will be automatically unchecked.


Cheers,
DragonSlayer
0
 
ginsonicAuthor Commented:
DragonSlayer, 150 points are your's already.

Because I found a way to solve my first half of my question , I will replace this with another one . Simple I think ( is the first time when I use a pop-up menu in my projects , so ... ) .

I need to know , when I click a radio button ( or any button ), what item is checked and to go to onSelect procedure of this item .

If another expert will give me the answer before DragonSlayer , then I will split the points .
0
 
ginsonicAuthor Commented:
I mean that I wish to know what pop-up item is checked and to go to OnSelect procedure of this item .
0
 
ginsonicAuthor Commented:
DragonSlayer,
I think that we have a problem here . The 150 points are still yours.

And for replaced part still available 150 points .

I lose here 600 points :(

Initial offered 300 points , but because no good suggestion I pending delete this request . But DragonSlayer give me a new comment ( stop my pending ) and the system take from my account new 300 points ?!?. Now ComTech paq this and lose another 300 points :(

But don't care . I will keep my word and I will offer the points into new questions ( Alike points for ...) .

So if have a solution for my last request put here the comment and I will offer the points into special requests .

Regards,
Nick

P.S. DragonSlayer, I wish to clarify my account problem with ComTech and then I will put a question for you . Sorry for delay .
0
 
ginsonicAuthor Commented:
DragonSlayer ,
At last monday I will give you the promise 150 points . I fix , with ComTech support , my account problem . But I must to resolve this question points problem.
OK?

Nick

P.S. Any suggestion for my last need ?
'I wish to know what pop-up item is checked and to go to OnSelect procedure of this item '

I will put a new question to offer the rest of 150 points to expert who can help me.

0
 
ginsonicAuthor Commented:
DragonSlayer take a look for points .
0
 
DragonSlayerCommented:
Here's something easy (sorry for the long delay, I was away for the weekend!)

either
1. put different value for the Tag parameter of the MenuItem and make them all share the same OnSelect procedure... this way you could do something like

procedure TForm1.OnSelect(Sender: TObject);
begin
  if not (Sender is TMenuItem) then
    Exit;
  TMenuItem(Sender).Checked := True;
  case TMenuItem(Sender).Tag of
    1: // do something for menu with tag 1
    2: // do something else for the other menu
    3: // etc etc
  end;
end;

or,

2.

if (Sender = mnuFileOpen1) then
  ...
else if (Sender = menuFileSave1) then
  ...


I personally prefer solution 1

:)



DragonSlayer.
0
 
DragonSlayerCommented:
Aiks! Sorry ginsonic, I failed to notice that you posted another Q regarding the OnSelect thingy, hehehe
0
 
DragonSlayerCommented:
hmm... I think I misunderstood your Question again, heh... check out Alan's comments in your other Q regardind OnSelect
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.