Solved

Pop-up and DB filtering problem

Posted on 2002-04-10
21
147 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
Comment Utility
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
Comment Utility
?  what about the moveby-method of tdataset
just an idea
0
 
LVL 4

Expert Comment

by:jsweby
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
umm... what pop-ups?
0
 
LVL 9

Author Comment

by:ginsonic
Comment Utility
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
Comment Utility
make it a radio button instead of a checkbox?
0
 
LVL 9

Author Comment

by:ginsonic
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 9

Author Comment

by:ginsonic
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
DragonSlayer take a look for points .
0
 
LVL 14

Expert Comment

by:DragonSlayer
Comment Utility
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
Comment Utility
Aiks! Sorry ginsonic, I failed to notice that you posted another Q regarding the OnSelect thingy, hehehe
0
 
LVL 14

Expert Comment

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

Featured Post

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

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Read about how to choose the best possible content marketing agency to suit your needs. Content marketing has become an integral part of running a successful tech business, so it is wise to be informed.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

743 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

13 Experts available now in Live!

Get 1:1 Help Now