N
nrms
Hi,
I have a form that displays a recordset of data from a table. I have a
textbox for users to enter a search string & a button labelled "Find" to do
the search. The OnClick event procedure is defined as:
Private Sub FindButton_Click()
On Error GoTo Err_FindButton_Click
Screen.PreviousControl.SetFocus
If Me!FindButton.Caption = "Find" Then
DoCmd.FindRecord "e", acAnywhere, , acSearchAll, False, acAll
Me!FindButton.Caption = "Next"
Else
DoCmd.FindNext
End If
Exit_FindButton_Click:
Exit Sub
Err_FindButton_Click:
MsgBox Err.Description
Resume Exit_FindButton_Click
End Sub
(Note I am currently testing with a fixed search string "e")
For some reason I cannot fathom, this procedure only partially works - it
finds the first occurrence of "e" and changes the button caption OK; but then
when I press the button a second time on the form, it should be executing a
FindNext method, but all that happens is the first occurrence of the "e" is
highlighted again.
What am I over-looking here?
Can anyone point me in the direction of examples of how to do this kind of
task?
Thanks
Nigel
I have a form that displays a recordset of data from a table. I have a
textbox for users to enter a search string & a button labelled "Find" to do
the search. The OnClick event procedure is defined as:
Private Sub FindButton_Click()
On Error GoTo Err_FindButton_Click
Screen.PreviousControl.SetFocus
If Me!FindButton.Caption = "Find" Then
DoCmd.FindRecord "e", acAnywhere, , acSearchAll, False, acAll
Me!FindButton.Caption = "Next"
Else
DoCmd.FindNext
End If
Exit_FindButton_Click:
Exit Sub
Err_FindButton_Click:
MsgBox Err.Description
Resume Exit_FindButton_Click
End Sub
(Note I am currently testing with a fixed search string "e")
For some reason I cannot fathom, this procedure only partially works - it
finds the first occurrence of "e" and changes the button caption OK; but then
when I press the button a second time on the form, it should be executing a
FindNext method, but all that happens is the first occurrence of the "e" is
highlighted again.
What am I over-looking here?
Can anyone point me in the direction of examples of how to do this kind of
task?
Thanks
Nigel