?
Solved

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

Posted on 2003-03-22
6
Medium Priority
?
140 Views
Last Modified: 2011-09-20
I feel like an idiot.  be gentle?

80083r
0
Comment
Question by:80083r
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 3

Accepted Solution

by:
ignacioperez earned 200 total points
ID: 8186117
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
 
LVL 2

Expert Comment

by:Jzaltheral
ID: 8186268
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
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 8187411
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!

 

Expert Comment

by:kevmeist
ID: 8189769
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
 

Expert Comment

by:kevmeist
ID: 8189884
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
 

Author Comment

by:80083r
ID: 8193626
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

Industry Leaders: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 4 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question