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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbKeyReturn

Status
Not open for further replies.

djeeten

Programmer
Mar 13, 2003
59
0
0
BE
Hi,

I have this logon form where a user has to give in his name and password. There are also 2 buttons on the form: Submit and Cancel. Now, I want to make sure that pressing the return button does the same as when pressing the button Submit.

So it should do this:

Private Sub Form_KeyPress(KeyAscii As Integer)
If (KeyAscii = vbKeyReturn) Then
Submit_Click
End If
End Sub

My problem is that within the company where I work, the return button functions as a tab button in access. Because of this, the code above does not satisfy.

Is there anyone who can tell me how I can take care of this using vba code? (so without changing anything in the access menu, as there are way too many pc's involved)

Thanks a lot in advance,

dj.

 
Setting the Default property of the button to True may well solve the problem. This means that if the Enter Key is hit while the form has focus (if no other button has the focus) the click event of this button will be executed.

Check out the Access help for more info.



There are two ways to write error-free programs; only the third one works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top