Solved

Pop-up and DB filtering problem

Posted on 2002-04-10
21
148 Views
Last Modified: 2013-11-28
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
0
Comment
Question by:ginsonic
  • 9
  • 7
  • 2
  • +2
21 Comments
 
LVL 4

Expert Comment

by:jsweby
ID: 6931633
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6932083
?  what about the moveby-method of tdataset
just an idea
0
 
LVL 4

Expert Comment

by:jsweby
ID: 6932196
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6932296
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
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6932880
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
 
LVL 9

Author Comment

by:ginsonic
ID: 6933047
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
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6933200
umm... what pop-ups?
0
 
LVL 9

Author Comment

by:ginsonic
ID: 6933651
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
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6935715
make it a radio button instead of a checkbox?
0
 
LVL 9

Author Comment

by:ginsonic
ID: 6935986
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
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 
LVL 9

Author Comment

by:ginsonic
ID: 6935990
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
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6935999
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
 
LVL 9

Author Comment

by:ginsonic
ID: 6936813
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
 
LVL 9

Author Comment

by:ginsonic
ID: 6936822
I mean that I wish to know what pop-up item is checked and to go to OnSelect procedure of this item .
0
 

Accepted Solution

by:
ComTech earned 0 total points
ID: 6936891
Points were awarded on seperate question, as stated above, therefore this question will be placed in PAQ.

Regards,
ComTech
CS @ EE
0
 
LVL 9

Author Comment

by:ginsonic
ID: 6936991
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
 
LVL 9

Author Comment

by:ginsonic
ID: 6938442
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
 
LVL 9

Author Comment

by:ginsonic
ID: 6939115
DragonSlayer take a look for points .
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6940908
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
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6940918
Aiks! Sorry ginsonic, I failed to notice that you posted another Q regarding the OnSelect thingy, hehehe
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6940922
hmm... I think I misunderstood your Question again, heh... check out Alan's comments in your other Q regardind OnSelect
0

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

This story has been written with permission from the scammed victim, a valued client of mine – identity protected by request.
Read about the 3 stages of the buyer's journey: awareness, consideration, and decision.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

896 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

11 Experts available now in Live!

Get 1:1 Help Now