The Find and Replace dialogs, separate dialogs in prior
Access versions and invoked by the keystrokes Control-F and Control-H
respectively (or by calling RunCommand) respectively, are now merged together
in Access 2000 to form a tabbed dialog.
Some developers have expressed their concerns, via email and newsgroup
posts, about the new dialog that they are not comfortable with the users
having such an easy access to the Replace portion of the dialog, when
all they want to use is the Find functionality.
Access 2000 does not provide any built in way to customize the new
Find/Replace dialog. However, if you mark the form or the table as Read-Only
before calling the dialog from code, Access will automatically hide the Replace
tab, since the user cannot make any changes in read-only mode.
The following procedures show how to open a form or a table in read-only
mode and then call the Find/Replace dialog from code.
Sub sFindReplaceInForm(strFormName As String)
On Error GoTo ErrHandler
Const ERR_GENERIC = vbObjectError + 6666
DoCmd.OpenForm strFormName, _
acNormal
With Forms(strFormName)
.AllowAdditions = False
.AllowDeletions = False
.AllowEdits = False
End With
DoCmd.SelectObject acForm, _
strFormName, _
False
DoCmd.RunCommand acCmdFind
ExitHere:
Exit Sub
ErrHandler:
Resume ExitHere
End Sub
Sub sFindReplaceInTable(strTableName As String)
On Error GoTo ErrHandler
Const ERR_GENERIC = vbObjectError + 6666
DoCmd.OpenTable strTableName, _
acViewNormal, _
acReadOnly
DoCmd.SelectObject acTable, _
strTableName, _
False
DoCmd.RunCommand acCmdFind
ExitHere:
Exit Sub
ErrHandler:
Resume ExitHere
End Sub
|