Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Close button on form

I have a form which opens when excel opens

If Sheets("SearchRoundsData").Range("B2").Value = 1 Then
frmWelcome.Hide
Else
frmWelcome.Show
End If

On the form there is a close button "CommandButton1". Is it possible to give
this button focus so that the user can use the Enter keyboard key rather
than having to click with the mouse?

Thanks
Sandy


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default Close button on form

in your userform_initialize sub, put

CommandButton1.setfocus

hth
:)
susan

On Jul 1, 10:57*am, "Sandy" wrote:
I have a form which opens when excel opens

* * If Sheets("SearchRoundsData").Range("B2").Value = 1 Then
* * * * frmWelcome.Hide
* * Else
* * * * frmWelcome.Show
* * End If

On the form there is a close button "CommandButton1". Is it possible to give
this button focus so that the user can use the Enter keyboard key rather
than having to click with the mouse?

Thanks
Sandy


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Close button on form

Hi Sandy

If you want CommandButton1 to have focus as the userform is shown, right
click on the userform, select tab order, bring CommandButton1 to the top.

Regards,
Per

"Sandy" skrev i meddelelsen
...
I have a form which opens when excel opens

If Sheets("SearchRoundsData").Range("B2").Value = 1 Then
frmWelcome.Hide
Else
frmWelcome.Show
End If

On the form there is a close button "CommandButton1". Is it possible to
give this button focus so that the user can use the Enter keyboard key
rather than having to click with the mouse?

Thanks
Sandy



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Close button on form

As usual never just one method :-)
Many thanks to you both.
sandy

"Sandy" wrote in message
...
I have a form which opens when excel opens

If Sheets("SearchRoundsData").Range("B2").Value = 1 Then
frmWelcome.Hide
Else
frmWelcome.Show
End If

On the form there is a close button "CommandButton1". Is it possible to
give this button focus so that the user can use the Enter keyboard key
rather than having to click with the mouse?

Thanks
Sandy


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Close button on form

As a user, I'm more used to using the Escape key to do the same as the Cancel
key and the Enter key to the same as the "ok" key.

You can accomplish this in your userform_initialize procedure with code like:

With Me.CommandButton1
.Caption = "Cancel"
.Cancel = True
'.Enabled = True
End With

With Me.CommandButton2
.Caption = "Ok"
.Default = True
'.Enabled = False
End With

If you really want to close the userform by hitting enter, you can use .default
= true on that commandbutton. (only one commandbutton can have those
properties.)



Sandy wrote:

I have a form which opens when excel opens

If Sheets("SearchRoundsData").Range("B2").Value = 1 Then
frmWelcome.Hide
Else
frmWelcome.Show
End If

On the form there is a close button "CommandButton1". Is it possible to give
this button focus so that the user can use the Enter keyboard key rather
than having to click with the mouse?

Thanks
Sandy


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Close X button on Usser Form Scardona Bay Viktor Excel Programming 1 March 14th 08 06:34 PM
Close user form when button is pressed april27 Excel Programming 1 June 16th 06 11:03 AM
Form Close Button ceemo[_37_] Excel Programming 3 October 12th 05 10:39 PM
Form Close button fran Excel Programming 2 September 16th 03 09:32 PM
SIMPLEST way to disable "close" button on form? codytheretriever Excel Programming 4 August 7th 03 09:00 PM


All times are GMT +1. The time now is 11:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"