Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Taking control from Option Button into RefEdit in Excel 2010 behaving oddly

Hi,

I have a form that have a set of Option Buttons (rdbOutRange, rdbNWB, and rdbNWS) and a RefEdit (redOutputRange).

When I select the Option Button (rdbOutRange), I want it put the cursor in the RefEdit (redOutputRange).

My current code does this. But if I select something else, and then reselect Option A, it doesn't work anymore.

It looks like that the code is stuck at the next line if I put a Breakpoint on the SetFocus line.

My code is the following:
Private Sub rdbOutRange_Change()

Application.EnableEvents = False
If Me.rdbOutRange.Value = True Then
Me.redOutputRange.Enabled = True
Me.redOutputRange.SetFocus
Else
Me.redOutputRange.Value = ""
Me.redOutputRange.Enabled = False
End If
Application.EnableEvents = True

End Sub

What I am doing wrong?

Thanks,
Mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Taking control from Option Button into RefEdit in Excel 2010behaving oddly

On Wednesday, January 29, 2014 7:30:49 PM UTC-6, wrote:
Hi,



I have a form that have a set of Option Buttons (rdbOutRange, rdbNWB, and rdbNWS) and a RefEdit (redOutputRange).



When I select the Option Button (rdbOutRange), I want it put the cursor in the RefEdit (redOutputRange).



My current code does this. But if I select something else, and then reselect Option A, it doesn't work anymore.



It looks like that the code is stuck at the next line if I put a Breakpoint on the SetFocus line.



My code is the following:

Private Sub rdbOutRange_Change()



Application.EnableEvents = False

If Me.rdbOutRange.Value = True Then

Me.redOutputRange.Enabled = True

Me.redOutputRange.SetFocus

Else

Me.redOutputRange.Value = ""

Me.redOutputRange.Enabled = False

End If

Application.EnableEvents = True



End Sub



What I am doing wrong?



Thanks,

Mike

this is a reach but .... could it be that the event is dead? Try something like

on error goto gracefull_exit

Application.EnableEvents = False
If Me.rdbOutRange.Value = True Then
Me.redOutputRange.Enabled = True
Me.redOutputRange.SetFocus
Else
Me.redOutputRange.Value = ""
Me.redOutputRange.Enabled = False
End If

gracefull_exit:

Application.EnableEvents = True
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Taking control from Option Button into RefEdit in Excel 2010behaving oddly

Thanks for the suggestion, it doesn't seem to be helpping me. I've also stopped using Application.EnableEvents as that doesn't actually stop form events from triggering.

I think I should be looking to see how I can get the radio button to trigger again without first clicking on another member of the group before clicking back to the button.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Taking control from Option Button into RefEdit in Excel 2010 behaving oddly

This works for me...

Private Sub opt1_Click()
With Me.RefEdit1
.Enabled = True: .SetFocus
End With
End Sub

Private Sub opt2_Click()
With Me.RefEdit1
.Enabled = True: .SetFocus
End With
End Sub

Private Sub opt3_Click()
With Me.RefEdit1
.Enabled = True: .SetFocus
End With
End Sub

Private Sub UserForm_Click()
Me.RefEdit1.Enabled = False
End Sub

Private Sub UserForm_Initialize()
Me.RefEdit1.Enabled = False
End Sub

...when clicking outside the RefEdit, then going back to choose another
option.

If setting state is needed then I recommend you use a separate routing
to manage that, and call that routine from the opt_Click event...

Private Sub opt1_Click()
With Me.RefEdit1
.Enabled = True: .SetFocus
End With
Call SetCtrlState(Ndx:=Me.opt1.Tag)
End Sub

Sub SetCtrlState(Ndx&)
Select Case Ndx
Case Is = 1: '//do this...
Case Is = 2: '//do that...
Case Is = 3: '//do some other thing...
End Select 'Case Ndx
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion



---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Taking control from Option Button into RefEdit in Excel 2010 behaving oddly

Oops! Forgot to convert type...
Private Sub opt1_Click()
With Me.RefEdit1
.Enabled = True: .SetFocus
End With


Call SetCtrlState(Ndx:=CLng(Me.opt1.Tag))

End Sub


...since the Tag is text. Optionally, you could avoid the conversion as
follows:

Sub SetCtrlState(Ndx$)
Select Case Ndx
Case "1":
Case "2":
Case "3":
End Select 'Case Ndx
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion



---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

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
UDF behaving oddly PBcorn Excel Programming 0 August 5th 08 03:09 PM
Select Case Behaving Oddly Kris_Wright_77 Excel Programming 3 June 6th 06 07:06 PM
OFFSET behaving oddly Ryan Poth Excel Worksheet Functions 2 May 30th 06 07:29 AM
=ISODD Behaving Oddly Craig[_15_] Excel Programming 5 April 30th 04 08:59 PM


All times are GMT +1. The time now is 04: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"