Home All Groups Group Topic Archive Search About
Author
30 May 2005 5:57 PM
Dan
I am using the graphical style of a check box to get a button on a form. Is
there a way to make one of these the one that is selected when the Enter key
is pressed?

-Dan

Author
30 May 2005 6:11 PM
Veign
You could set the KeyPreview property of the form to true and trap the
return key being pressed in the form's KeyPress event.  This will not work
if there is a command button on the form with its Default property set to
true.

Private Sub Form_KeyPress(KeyAscii As Integer)

If KeyAscii = vbKeyReturn Then
    chkCheck1.Value = vbChecked
End If

End Sub

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/


Show quoteHide quote
"Dan" <D**@discussions.microsoft.com> wrote in message
news:C101CC75-09CE-46F3-9C0E-199D7409131A@microsoft.com...
> I am using the graphical style of a check box to get a button on a form.
Is
> there a way to make one of these the one that is selected when the Enter
key
> is pressed?
>
> -Dan
Are all your drivers up to date? click for free checkup

Author
30 May 2005 8:44 PM
Dan
Thank you! I'll try what you suggested.

-Dan

Show quoteHide quote
"Veign" wrote:

> You could set the KeyPreview property of the form to true and trap the
> return key being pressed in the form's KeyPress event.  This will not work
> if there is a command button on the form with its Default property set to
> true.
>
> Private Sub Form_KeyPress(KeyAscii As Integer)
>
> If KeyAscii = vbKeyReturn Then
>     chkCheck1.Value = vbChecked
> End If
>
> End Sub
>
> --
> Chris Hanscom - Microsoft MVP (VB)
> Veign's Resource Center
> http://www.veign.com/vrc_main.asp
> --
> Read. Decide. Sign the petition to Microsoft.
> http://classicvb.org/petition/
>
>
> "Dan" <D**@discussions.microsoft.com> wrote in message
> news:C101CC75-09CE-46F3-9C0E-199D7409131A@microsoft.com...
> > I am using the graphical style of a check box to get a button on a form.
> Is
> > there a way to make one of these the one that is selected when the Enter
> key
> > is pressed?
> >
> > -Dan
>
>
>

Bookmark and Share