Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: DoCmd.FindRecord Method seems to have a few problems


Message #1 by "Howard Ronald Brown Jr." <rbrown@n...> on Thu, 27 Sep 2001 01:41:04
The DoCmd.FindRecord method is intended to expose the functionality of the 

Edit/Find menu option to programming.  This is very nice for altering the 

default behavior of the find dialog's control settings.  However, it 

differs in a few important ways.  Some of these seem to be bugs and a 

general lack of documentation to show how to use the method efficiently.  

First the bugs:



The SearchAsFormatted option is supposed to accept a false value, but if 

you try and pass this to the method you will get an error message, which 

isn't particularly helpful.



The Search option's acSearchAll doesn't automatically consider the entire 

record set, but works mor like the adDown option.  I had to add explicit 

code to reposition the recordset to its beggining so that I could use this 

option properly.



When this method is executed repeatedly, each match that is found is 

highlighted as normal. However, the when the Next Find is issued the 

highlighting on the previous matched text is not always cleared.  This 

behavior is different than the Edit/Find menu version and can irritate the 

user, so could be considered a bug.



The documentation issues -

Both the FindRecord Action and Method Help text say that the Search As 

Formatted option default to False if the positional argument isn't 

supplied in the call.  However, in my verion of Access 2000 the checkbox 

on the Edit/Find menu option show this as a greyed out, but checked 

checkbox, which implies that the option should default to True.  Also, in 

light of the fact that if you try in use a False value you will get an 

error - see above.



None of the documentation tell how to determin that a match is not found.  

When FindRecord executes, but doesn't find a match, the pop-up message 

that normally displays with the Edit/Find menu option is not displayed.  

This would be fine if it were discussed and code was supplied showing how 

to determine if the find was successful or not.



Again, great command, but needs work Microsoft.
Message #2 by "Howard Ronald Brown Jr." <rbrown@n...> on Sat, 29 Sep 2001 00:42:00
I'm still stuggling with the DoCmd.FindRecord command.  Here are a couple 

of work-arounds I'm using:



If the same record contain more than one march, then the previous matches 

in that record are not cleared - before running the DoCmd.FindRecord 

command again, programmatically deselect the ActiveControl's hightlight by 

advancing it's SelStart one character and setting the SelLength to zero.



The user isn't notified if no match is found - This one is tricky enough, 

but it gets really tricky if you're trying to search on a form that has a 

subform.  Basically, you have to compare the AbsolutePosition of the 

Form's recordset before and after the DoCmd.FindRecord.  If they differ 

then a match was found.  However, if they are the same then you need to 

compare the before and after ActiveControls to see if they differ.  If so 

then a matach was found.  Finally, you need to compare the selected text 

to see if it's position and content differ.  Again, if so then another 

match was found.  If all of these are the same or no text is selected then 

you know that a match was not found.  Now for the really tricky part.  

Because the ActiveControl may point to various types of controls, which 

may not all have the same properties, you will need to check to see that 

the SelText, SelStart and SelLength properties exist before trying to 

access them.  I'm not sure that this covers all of the possible snags, but 

it seems to work.  Boy I wish that Microsoft had enabled the NoMatch 

property!  That would have made this a log easier.  Microsoft, please make 

the DoCmd.FindRecord truely equivalent to the menu Find command.

  Return to Index