LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Undo a scroll action

Sorry it didn't work for you.

I'm out of suggestions.

joeeng wrote:

Dave,

After trying this again, it does not work. After ScrollBar1.change executes
with the scrollbar1.value changed to the starting value, it executes one more
time with blkproc=false and with the scrollBar1 ending value, probably pulled
from the stack, negating the change.

"Dave Peterson" wrote:

I made a small userform with a scrollbar and a label.

This seemed to work ok for me:

Option Explicit
Dim BlkProc As Boolean
Dim ScrollBar1Pos As Double
Private Sub ScrollBar1_Change()
Dim Resp As Long
If BlkProc = True Then Exit Sub

Resp = MsgBox(Prompt:="Are you sure", Buttons:=vbYesNo)

If Resp = vbYes Then
ScrollBar1Pos = Me.ScrollBar1.Value
Else
BlkProc = True
Me.ScrollBar1.Value = ScrollBar1Pos
BlkProc = False
End If
Me.Label1.Caption = Me.ScrollBar1.Value
End Sub
Private Sub UserForm_Initialize()
With Me.ScrollBar1
.Min = 0
.Max = 100
.LargeChange = 10
.SmallChange = 1
.Value = 0
ScrollBar1Pos = .Value
End With
Me.Label1.Caption = Me.ScrollBar1.Value
End Sub




joeeng wrote:

I was trying to use a validation check (i.e., Are you sure you want to scroll
before saving current data?, vbYesNoCancel & vbQuestion) within the
Scrollbar_Change procedure and, if the user chooses Cancel, the form and
scrollbar revert back to the condition before the Scrollbar_Scroll action.
The problem, even with your suggestion, is that the Scrollbar change event is
always triggered upon unclicking the scrollbar and the Scrollbar change event
for the scroll change action is always the last to execute which negates the
manual change of the scrollbar position when Cancel is requested from within
the Scrollbar_Change procedure. It seems to be a hieracrchical thing; the
manual Scroll change completes its event procedure before the scroll action
change does because the manual change is called from within the scroll change
procedure.

"Dave Peterson" wrote:

Maybe you can use a variable that serves as a go/no-go indicator:

'At the top of the module, but not in any procedure
Dim BlkProc as boolean

'in your procedu
Private sub ...

if blkproc = true then exit sub

....other stuff

'change the value

blkproc = true
'do the change
blkproc = false

'do more stuff
End Sub

But if you don't want the scrollbar to be changed, why design the form to have a
scrollbar?

joeeng wrote:

Is there a way to undo a scroll action by a scrollbar on a userform? If I
try to manually reset scrollbar.value from within the Scrollbar_Change event
procedure, it triggers the scrollbar_change again, and reverts to the
scrolled scrollbar value upon completion of the stacked change event because
there form events cannot be disabled. I have tried the BeforeUpdate event,
which triggered as expected but either I don't know how to use the Cancel or
it does not work even though Microsoft Help says it applies to scrollbars.
The userform UndoAction only seems to undo text changes in the userform.

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
 
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
How can i undo an action after i have clicked save. missy Excel Discussion (Misc queries) 2 December 8th 08 05:43 PM
How to undo the delete action? ABS Excel Discussion (Misc queries) 2 April 16th 08 05:30 PM
Undo VB macro action Fan924 Excel Programming 1 October 20th 07 06:17 AM
Undo a save action John Excel Discussion (Misc queries) 1 January 26th 06 06:26 PM
undo/redo action dmuraki Excel Discussion (Misc queries) 3 November 30th 04 12:11 AM


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