Deactivating Multipage Change Event

M

marston.gould

I have the following code in a UserForm....

Sub Multipage1_Change()
If UserForm1.ListBox2.ListCount = 0 And UserForm1.Multipage1.Value > 0
Then
Application.EnableEvents = False
UserForm1.Multipage1.Value = 0
MsgBox "Please make selection"
End If
End Sub

However when I "watch" this process, I notice that even though the
Application.EnableEvents = False executes, when I go to set the
UserForm back to Multipage1.Value = 0, the subroutine treats it like a
change and goes back to the top again.

Is there something special I have to do temporarily deactivate an event
in a userform? or a change event?
 
B

Bob Kilmer

see embedded

I have the following code in a UserForm....

Sub Multipage1_Change()

Static blnIgnoreChange As Boolean
If blnIgnoreChange Then Exit Sub
blnIgnoreChange = True
If UserForm1.ListBox2.ListCount = 0 And UserForm1.Multipage1.Value > 0
Then
Application.EnableEvents = False
UserForm1.Multipage1.Value = 0
MsgBox "Please make selection"
End If

blnIgnoreChange = False
 
D

Dave Peterson

Use a boolean variable and keep track yourself:

Dim blkProc as boolean
Sub Multipage1_Change()
if blkproc then exit sub
If UserForm1.ListBox2.ListCount = 0 And UserForm1.Multipage1.Value > 0 Then
blkproc = true
UserForm1.Multipage1.Value = 0
blkproc = false
MsgBox "Please make selection"
End If
End Sub
 

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