Configure control specific enter key behavior

mdlueck

Sr. Application Developer
Local time
Today, 02:24
Joined
Jun 23, 2011
Messages
2,649
Is there a way to, on one paticular control (text field) trap for the Enter key and on the rest of the form have "Enter = Commit" button?

I would like that when you are in the search field, if you press enter that it would push the search button.

I tried putting:

Code:
Private Sub fldPartNumberSearch_KeyPress(KeyAscii As Integer)

Debug.Print KeyAscii

End Sub
But the Enter key always jumps me to the Commit button, and I do not see the event fire in the Immediate window's output.

I even went as far as commenting out:

Code:
btnCommit.Default = True
in the Form_Load event and it does not undo the association.

So, is there an Rx for a control specific alternate Enter key behavior?
 
I even went as far as commenting out:

Code:
btnCommit.Default = True
in the Form_Load event and it does not undo the association.
Hints:
* Don't you think you should find an event that will undo this association?
* Are you sure the Load event of the FORM is the right event to associate this control to the button?
 
Hints:
* Don't you think you should find an event that will undo this association?

I would think merely commenting the LOC, save, close the DB, and reopen should be enough to flush the association. No? If not, then where else has the association been remembered?

* Are you sure the Load event of the FORM is the right event to associate this control to the button?

I have seen in other's code suggestions to associate Form default buttons in the Load event. Thus coding in similar style in this case. Do you have an alternate suggestion as to where to place such LOC's?
 
No? If not, then where else has the association been remembered?

Button Properties \ Other tab \ "Default" and "Cancel" of both the Commit and Rollback buttons are all set to No.

Evidently there was at least one other spot.
 
Simply:
* Associate - Got Focus event of the control
* Dissacociate - Lost Focus event of the control
 
Simply:
* Associate - Got Focus event of the control
* Dissacociate - Lost Focus event of the control

Ohhhh, and try to over-ride the Form default while only this control has focus. I will code that up and see how it works. Thanks! ;)
 
Aaaahhh... MUCH better!

Code:
Private Sub fldPartNumberSearch_GotFocus()

  Me.btnCommit.Default = False
  Me.btnSearch.Default = True

End Sub

Private Sub fldPartNumberSearch_LostFocus()

  Me.btnSearch.Default = False
  Me.btnCommit.Default = True

End Sub

Thanks! :D
 

Users who are viewing this thread

Back
Top Bottom