> Keep in mind that the default command button will fire *whenever*
Enter is pressed (excluding other buttons). So if you press Enter in
another text box the default button fires. That's what setting it as
the default button does.
I see. You are correct - the command button does fire whenever Enter is
pressed. I set the command button Default property back to "No" and
modified the code:
Private Sub txtFind_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
DoCmd.RunCommand acCmdSaveRecord
Call cmdFind_Click
End If
End Sub
For some reason I have to save the record. The text box is unbound, so I'm
not sure why. If I just try to requery the text box like this:
Private Sub txtFind_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Me!txtFind.Requery
Call cmdFind_Click
End If
End Sub
I get an error:
Error Number 2118: You must save the current field before you run the
Requery action.
PS. I always use the Call keyword for readability, but yes, it is not
necessary.