Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with SetRange

Status
Not open for further replies.

RuneGol

Programmer
Nov 9, 2005
1
SE
The program only detects the last Table1.SetRange. Could somebody please explain how to make it detect all of them?
Thanks in advance!


Code:
procedure TRappUt1fB.BitBtn1Click(Sender: TObject); //Här sker granskning
begin
with RappUt1fB do
if Edit1.Text = '' then Edit1.Text := '0';
if Edit2.Text = '' then Edit2.Text := '99999999';
if Edit3.Text = '' then Edit3.Text := '0';
if Edit4.Text = '' then Edit4.Text := '99999999';
if Edit5.Text = '' then Edit5.Text := '0';
if Edit6.Text = '' then Edit6.Text := '99999999';
Table1.SetRange ([Edit1.Text], [Edit2.Text]);
Table1.SetRange ([Edit3.Text], [Edit4.Text]);
Table1.SetRange ([Edit5.Text], [Edit6.Text]);
QuickRep1.Preview;
Edit1.Text := '';
Edit2.Text := '';
Edit3.Text := '';
Edit4.Text := '';
Edit5.Text := '';
Edit6.Text := '';
end;
 
I would do it with an onfilter event

procedure TRappUt1fB.BitBtn1Click(Sender: TObject); //Här sker granskning
begin
table1.filtered := true;
if Edit1.Text = '' then Edit1.Text := '0';
if Edit2.Text = '' then Edit2.Text := '99999999';
if Edit3.Text = '' then Edit3.Text := '0';
if Edit4.Text = '' then Edit4.Text := '99999999';
if Edit5.Text = '' then Edit5.Text := '0';
if Edit6.Text = '' then Edit6.Text := '99999999';
QuickRep1.Preview;
Edit1.Text := '';
Edit2.Text := '';
Edit3.Text := '';
Edit4.Text := '';
Edit5.Text := '';
Edit6.Text := '';
end;


procedure TDM.Table1FilterRecord(DataSet: TDataSet; var Accept: Boolean);
begin
accept := false;
if (Table1.fieldbyname('field').asinteger >=strtoint(Edit1.Text)) and (Table1.fieldbyname('field').asinteger >=strtoint(Edit1.Text)) then
accept := true;
if (Table1.fieldbyname('field').asinteger >=strtoint(Edit3.Text)) and (Table1.fieldbyname('field').asinteger >=strtoint(Edit4.Text)) then
accept := true;
if (Table1.fieldbyname('field').asinteger >=strtoint(Edit5.Text)) and (Table1.fieldbyname('field').asinteger >=strtoint(Edit6.Text)) then
accept := true;
end;



code written here NOT tested :)
 
A dataset can only have one range in force at a time. You can't define three or four and have them exist simultaneously, unfortunately.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top