Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Search Memo on filtered database

Posted on 2002-03-25
2
146 Views
Last Modified: 2010-04-04
I am using Topaz V7.51 BDE replacement (www.softsci.com)

The software has a procedure to search on a memo field for a string -
 
LocateRec(FieldName:string; var FieldValue);

e.g.
.....
var
 MyString: string;
begin
 MyString := 'A Company';
 MyTable.LocateRec('COMPANY', MyString);
......

if the search string is found a call to another

procedure Continue;

e.g.
.....
 MyTable.Continue;
.....

resumes the search for another occurance of the string. This can be called repeatedly until the end of the database is reached.
The problem is that the procedure does not respect filters and i wish to search on filter ranges. I have found an undocumented function used internally by Topaz to detect if the current record is in the filter range.

function RecordInFilterRange: Boolean

I wish to use this to detect if a matching string is in the filter range, If it is in the filter range stop then a call can be made to Continue or if it is not ignore it and continue to the next match etc. I wish to use 2 buttons (Locate & Continue) to achieve this functionality.
 Any help would be appreciated.

Regards
Paul.  
0
Comment
Question by:pr_wainwright
2 Comments
 
LVL 17

Accepted Solution

by:
geobul earned 150 total points
ID: 6896431
Hi,
Something like:

// locates first record within a range
// returns true = found and false = not found
function LocateRecFiltered(TheTable: TypeOfMyTable; FieldName:string; var FieldValue): boolean;
begin
 result := false;
 try
  with TheTable do begin
   LocateRec(FieldName, FieldValue);
   if not EOF then begin
    while (not EOF) and (not RecordInFilterRange) do begin
      Continue;
    end;
    if not EOF then result := true;
   end;
  end;
 except
  result := false;
 end;
end;

// continues searching
// returns true = found and false = not found
function ContinueFiltered(TheTable: TypeOfMyTable): boolean;
begin
 result := false;
 try
  with TheTable do begin
   Continue;
   if not EOF then begin
    while (not EOF) and (not RecordInFilterRange) do begin
      Continue;
    end;
    if not EOF then result := true;
   end;
  end;
 except
  result := false;
 end;
end;

Usage:
// Locate button
procedure TForm1.Button1Click(Sender: TObject);
begin
  if not LocateRecFiltered(MyTable, 'COMPANY', Edit1.Text) then ShowMessage('Record not found');
end;

// Continue button
procedure TForm1.Button2Click(Sender: TObject);
begin
  if not ContinueFiltered(MyTable) then ShowMessage('There are no more records found');
end;

Replace 'TypeOfMyTable' with the actual type in both function definitions. I presume that there are MyTable.EOF property and MyTable.RecordInFilterRange method.

Regards, Geo
0
 
LVL 1

Author Comment

by:pr_wainwright
ID: 6898714
Just the trick !
Thanks
Paul.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

808 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