Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!rochester!bbn!ginosko!uunet!accur8!emuleomo From: emuleomo@accur8.UUCP (Olumide Emuleomo) Newsgroups: comp.databases Subject: Re: Avoiding SET FILTER TO command Message-ID: <260@accur8.UUCP> Date: 31 Jul 89 22:44:49 GMT References: <472@uncmed.med.unc.edu> Organization: Accurate Information Systems, Inc. Lines: 43 In article <472@uncmed.med.unc.edu>, danielg@uncmed.med.unc.edu writes: > Dear dBASE friends, > > I have a problem to which I *know* there is a simple answer. I > have to locate a record in my database by two fields. I have > tried SET FILTER TO the first, then using a FIND command to > pinpoint my record, but as you might expect, this is ** much too > slow ***. > > Please post, or e-mail to me. > > Thanks. Luckily, this is a simple problem. All you have to do is Index your DBF on one of the flds, say fld1 and write the following code.... USE INDEX idx1 SET EXACT ON SEEK value_1 && This searches the index on fld1 IF .NOT. FOUND() RETURN(.F.) && Since both flds have to match, no match is now possible! ENDIF DO WHILE fld_1 = value_1 .AND. .NOT. EOF() IF fld_2 = value_2 RETURN(.T.) ENDIF SKIP ENDDO RETURN(.F.) && Value not found!! Off course, you may need to CLOSE your DBF and etc... but the above code should return .T. if both values are in your DBF. If you are using dBASE III+ that does not have UDFs then pass a parameter to the above and set the value to .T. or .F. as needed. You may then test it in the calling pgm. GOOD LUCK Emuleomo O O (emuleomo@accur8@uunet.uu.net)