• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 143
  • Last Modified:

How do I make a button that is the default when I press enter?

I feel like an idiot.  be gentle?

80083r
0
80083r
Asked:
80083r
1 Solution
 
ignacioperezCommented:
I'm not so sure what you're asking, but I guess what you want is to make a button your default button in the form. To do that, you only have to set the "Default" property (you can do that at design time) of your command to "true"
0
 
JzaltheralCommented:
On the other hand, if what you want to do is make a button the default on a message box, you tell VB in the code that calls the message box.

For example:

    MsgBox "Some text here that I want to share.", vbYesNo + vbDefaultButton2

This code would display a yes no message box and make the 2nd button (the No) the default.  If you wanted yes to be default, technically you could change vbDefaultButton2 to vbDefaultButton1, but that's not needed, as the first button is the default automatically, unless you tell vb you want it otherwise.

Hope that helps.

Jzal
0
 
Arthur_WoodCommented:
you have the answer already...Simply set the Default property of the Command Button in question to TRUE.  That becomes the Button that is clicked when the user presses the Enter Key...Is that what you mea?

AW
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
kevmeistCommented:
Alternatively, you can set the tabindex property at design time to control which fields the user can tab through at run-time. Set non tabbed fields to 0. Set the default control to a value of 1.

Kevin
0
 
kevmeistCommented:
BTW, you will also have to set the TABSTOP property to False for any text boxes that you don't wish to be in the tabbing order.

Kevin
0
 
80083rAuthor Commented:
yup, that's exactly what I was asking.  It was a brain fart.  (pppppphhhhhhhlllllllbbbbbTTTTTT!!!!) I think some brains just leaked out my ear. :)

Thanks everyone.

Incidentally, the cmd button set to default remains the default if enter is pressed, correct?  What happens if I have a multiline textbox in the form, and the user presses enter there?

I suppose I could do a runtime set of the default propert on gotfocus() and lostfocus() ?

thanks,

80083r

-someday they are going to pay me for all this programming.
-until then, it will be full of bugs, and take exceptionally long periods of time to develop.  Solitaire anyone?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now