Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with default property

Status
Not open for further replies.

angelpr23

Programmer
Mar 15, 2007
37
GR
Hello all.
I have created a from with 3 textboxes and 3 command buttons. I display a record in text boxes and the user modify its values, so my command buttons is saveCmd, CancelCmd and HelpCmd. I set saveCmd default property to true. Well, if the user modify a value of a field in the record, if i click in save button the changes are saving and everything runs properly, but if press enter it sheems like saving changes but it doesn't do. I am not getting erros and this is strange. I tried to run it step by step and everything runs properly, i cant understand what exactly happens and i want to solve it. Any help will be much appriciated.

Thank you
in advanced.
 
First point: the standard naming convention for command buttons is to prefix the name with cmd. So, more in line with convention is cmdSave, cmdHelp, etc.

To teach yourself what's going on here, make a new project. Add 3 command buttons, and 1 text box. Put in this code:
Code:
Option Explicit

Private Sub Command1_Click()
MsgBox "1"
End Sub

Private Sub Command2_Click()
MsgBox "2"
End Sub

Private Sub Command3_Click()
MsgBox "3"
End Sub

Now, set the default property on Command2 to true. Click on various command buttons, and then hit enter. You'll see that whichever command button was last clicked is the one that the enter key selects. Now, click in the text box, and hit enter again. You'll see that Command2 is pressed.

Keep in mind that a user can tab to a command button and press enter to select it. Microsoft has always provided ways to navigate in windows without the mouse, since some types of physical handicap make it impossible to use the mouse. So, the point is that you can't do precisely what you want in this manner. The way you could do it is to intercept the enter key and call the event handler, but I don't believe I'd recommend that personally.

In short...."This behavior is by design."

HTH

Bob
 
Thank you very much BobRodes. I finally found my mistake somewhere else. I was saving the changes of the record with rs.update statement, i had an information message for the user that the changes saved and under rs.update and it was really strange, that when i was hitting enter the message was appering but no changes were saving. I tried rs.UpdateBatch adAffectCurrent and the changes are now saving. Thank you very much for your patience.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top