Jump to content
bazzer747

RadioGroup Oddity

Recommended Posts

Hi,

I have a table which has an internal calculated field nHcap. It is a numeric field with values from 1 to 54. In the table I have another field which has a value of either 'Div 1', 'Div 2', or 'Div 3'. 

I use a RadioGroup with these three values available for selection, and when a selection is made I filter the table to show only records that have a certain nCap value. These values are 'Div 1' from 1 to 17, 'Div 2' from 14 to 21, and 'Div 3' from 20 to 54.   The OnCLick event for the RadioGroup looks like this:

procedure TfLadyMembers.rgDivsClick(Sender: TObject);
var
  cChoice: String;
begin
dm.vMembers.Filtered:= False;   //Start with clean slate

cChoice:= rgDivs.Items[ rgDivs.ItemIndex ];
with dm.vMembers do
  begin
    if cChoice = 'Div 1' then Filter:= 'nHcap < 17';
    if cChoice = 'Div 2' then Filter:= 'nHcap > 13 AND nHcap < 21';
    if cChoice = 'Div 3' then Filter:= 'nHcap > 20';
    Filtered:= True;
  end;
if cChoice = 'All' then dm.vMembers.Filtered:= False;
end;

 

The problem I'm seeing is that when 'Div 1' is first clicked the filter gives incorrect records. Clicking the other buttons gives correct results, and subsequent clicks on 'Div 1' gives the correct results. I've traced the code in debug mode and the correct select/filtering is executed, so why am I getting incorrect records on the first selection. Very odd.

 

Share this post


Link to post

An extra 'oddity' is that when the first click on 'Div 1' produces the wrong set of records I sometimes get an error message to the effect a Bookmark is not found. I am not using Bookmarks so this is something internal.

RadioGroupOddity.jpg

Share this post


Link to post

An extra 'oddity' is that when the first click on 'Div 1' produces the wrong set of records I sometimes get an error message to the effect a Bookmark is not found. I am not using Bookmarks so this is something internal.

Share this post


Link to post

Just to finish this off, as no one has replied :-).

I've changed from using Filter (as this fails with strange error conditions and incorrect results) to using SetRange, which works perfectly, and much quicker. 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×