Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default problem :Onclick event occurs after a Setfocus

hi there ,

On a userform , I have several textboxes and a listbox in a frame.
The listbox is the last object in the tabstop order in that frame.
On top of the form there is a commandbutton .

Each time when I push the ENTER key in the frame the tabstop moves to the
next object until it reaches the listbox.
To move to the next object ( the commandbutton ) from the listbox , I put
some code behind the listbox.Keydown event i found on the net.

Private Sub LstType_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
If KeyCode = 13 Then
Me.Commandbutton1.SetFocus
End If
End Sub

This works fine to move to the commandbutton , but when it gets the focus it
runs the On_click code.
I just want to get the focus on the commandbutton , not to execute the code
behind the button.

Is there a solution for this.

Kind regards for helping me .
Mario


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default problem :Onclick event occurs after a Setfocus

Can't you set the frame tabindex to 1 lower than the commandbutton, then it
should tab normally?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"MarMo" wrote in message
...
hi there ,

On a userform , I have several textboxes and a listbox in a frame.
The listbox is the last object in the tabstop order in that frame.
On top of the form there is a commandbutton .

Each time when I push the ENTER key in the frame the tabstop moves to the
next object until it reaches the listbox.
To move to the next object ( the commandbutton ) from the listbox , I put
some code behind the listbox.Keydown event i found on the net.

Private Sub LstType_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
If KeyCode = 13 Then
Me.Commandbutton1.SetFocus
End If
End Sub

This works fine to move to the commandbutton , but when it gets the focus

it
runs the On_click code.
I just want to get the focus on the commandbutton , not to execute the

code
behind the button.

Is there a solution for this.

Kind regards for helping me .
Mario




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default problem :Onclick event occurs after a Setfocus

Hi Mario,

Try Keyup instead of Keydown

Regards,
Peter T

"MarMo" wrote in message
...
hi there ,

On a userform , I have several textboxes and a listbox in a frame.
The listbox is the last object in the tabstop order in that frame.
On top of the form there is a commandbutton .

Each time when I push the ENTER key in the frame the tabstop moves to the
next object until it reaches the listbox.
To move to the next object ( the commandbutton ) from the listbox , I put
some code behind the listbox.Keydown event i found on the net.

Private Sub LstType_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
If KeyCode = 13 Then
Me.Commandbutton1.SetFocus
End If
End Sub

This works fine to move to the commandbutton , but when it gets the focus

it
runs the On_click code.
I just want to get the focus on the commandbutton , not to execute the

code
behind the button.

Is there a solution for this.

Kind regards for helping me .
Mario




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default problem :Onclick event occurs after a Setfocus

Peter , Bob
First , I tried the taborder changes Bob suggested , but witout success.
Again the code was run when pressing ENTER on the listbox.

I tried the KeyUp , but it did the same as Keydown = Set focus to the button
and executes the code behind it.
Now I tried the KeyPress event , and this seems to work correctley for me.
It set's the focus on the button , and does not run the code.

Thanks you again for your replies.
Write to you again for a next question.
Greetz
Mario


"Peter T" <peter_t@discussions wrote in message
...
Hi Mario,

Try Keyup instead of Keydown

Regards,
Peter T

"MarMo" wrote in message
...
hi there ,

On a userform , I have several textboxes and a listbox in a frame.
The listbox is the last object in the tabstop order in that frame.
On top of the form there is a commandbutton .

Each time when I push the ENTER key in the frame the tabstop moves to the
next object until it reaches the listbox.
To move to the next object ( the commandbutton ) from the listbox , I put
some code behind the listbox.Keydown event i found on the net.

Private Sub LstType_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
If KeyCode = 13 Then
Me.Commandbutton1.SetFocus
End If
End Sub

This works fine to move to the commandbutton , but when it gets the focus

it
runs the On_click code.
I just want to get the focus on the commandbutton , not to execute the

code
behind the button.

Is there a solution for this.

Kind regards for helping me .
Mario






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
Change event occurs Otto Moehrbach Excel Programming 2 December 2nd 05 04:53 PM
OnClick event lilika Excel Programming 2 February 22nd 05 05:34 PM
dynamic hyperlink or onclick event Tasha Excel Programming 2 February 16th 05 01:57 PM
onclick event for cell ties Excel Programming 4 July 20th 04 12:09 PM
event which occurs when a TextBox receives focus Mikhail Excel Programming 2 October 7th 03 02:27 PM


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

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

About Us

"It's about Microsoft Excel"