command button and the "enter" and "tab" keys

G

Guest

I have an extensive macro that works when my command button titled
" Private Sub registrationcomplete_Click() " is clicked.

I have a series of text boxes that are programmed to tab to the next text
box and ultimately to the command box in question. When this series of
textbox's and tabs get to the command box the command box is highlighted.

I would like to be able to activate the command box by either clicking on it
or pressing enter since it is already highlighted.

I am not sure if the command to allow entering to activate the command box
can be entered into the "click" macro above or if a separate macro must be
written?

Suggestions?
 
D

Dave Peterson

And if you have a button that cancel's the form, you may want to change its
Cancel property to True. Then you can hit the escape key to close the form.
 
G

Guest

In my command button properties there is no "default" property. I dont see
the "defualt" property in the object browser either?

Where are these located?
 
D

Dave Peterson

This is in a userform (with the VBE), right?

If yes, go to the VBE
select your userform
select the ok button
hit F4 to see the properties

Look for the Default property and change it there.
 
G

Guest

Dave,
I do not understand how? where ? to apply the cancel property and or the
default property. I did find these finally under help in VBA.

what is the syntax

commandbutton1.default= "true"

If so where do you put this? at the beginning of the macro i already have
written for this button?
 
D

Dave Peterson

I'd put it in the userform_initialize routine. And I'd drop the double quotes.
Just use the plain old Boolean value True.

But you have another reply in the other branch.

dr said:
Dave,
I do not understand how? where ? to apply the cancel property and or the
default property. I did find these finally under help in VBA.

what is the syntax

commandbutton1.default= "true"

If so where do you put this? at the beginning of the macro i already have
written for this button?
 
T

Tom Ogilvy

In my opinion, better to set it in design mode in the VBE. doesn't sound
like something that would need to be changed.

Set it like any property of a control - using the properties window.
 
D

Dave Peterson

That was my reply in the other branch <bg>.

But a couple of good reasons to use code might be so that you could copy|paste
to other userforms and not have to remember to change the properties manually.

And it's easier to explain using sample code rather than how to get to the
properties window <vvbg>.



Tom said:
In my opinion, better to set it in design mode in the VBE. doesn't sound
like something that would need to be changed.

Set it like any property of a control - using the properties window.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top