PC Review


Reply
Thread Tools Rate Thread

Close button on form

 
 
Sandy
Guest
Posts: n/a
 
      1st Jul 2008
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


 
Reply With Quote
 
 
 
 
Susan
Guest
Posts: n/a
 
      1st Jul 2008
in your userform_initialize sub, put

CommandButton1.setfocus

hth

susan

On Jul 1, 10:57*am, "Sandy" <sandy_step...@DELETEhotmail.com> 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


 
Reply With Quote
 
Per Jessen
Guest
Posts: n/a
 
      1st Jul 2008
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" <(E-Mail Removed)> skrev i meddelelsen
news:2A85E0C5-1C11-4846-8861-(E-Mail Removed)...
>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
>
>


 
Reply With Quote
 
Sandy
Guest
Posts: n/a
 
      1st Jul 2008
As usual never just one method :-)
Many thanks to you both.
sandy

"Sandy" <(E-Mail Removed)> wrote in message
news:2A85E0C5-1C11-4846-8861-(E-Mail Removed)...
> 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
>
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      1st Jul 2008
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
button to open form export to Excel and close form deb Microsoft Access Forms 1 25th Jun 2008 02:27 PM
Have to click "Close" button three times to close dialog form Michael Fuchs Microsoft Access Form Coding 0 6th Aug 2006 11:37 AM
Close button on a form will not close form - error 2585 - action cannot be carried out while processing a form Angus Comber Microsoft Access 2 19th Jul 2006 12:21 PM
Command Button Open form / Close form =?Utf-8?B?cGRiZXJnZXI=?= Microsoft Access Forms 1 15th Feb 2006 06:21 PM
Button To open new form does not close the main form Veli Izzet Microsoft Access 7 25th Jul 2005 01:41 PM


Features
 

Advertising
 

Newsgroups
 


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