Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

make undo button visible if anything changes 2

Status
Not open for further replies.

mavog

IS-IT--Management
Jun 12, 2003
25
GB
Hi ,
is there an easy way to make an 'undo changes' button visible but only when there are changes made in any fields on a form?
 
yes, this should help you:

If Me.Dirty Then
Me.UndoChangesButton.Visible = False
End If
 
Sorry about that first post, I thought I'd hit the stop button fast enough ;) Now this is correct:

If Me.Dirty Then
Me.UndoChangesButton.Visible = True
End If


You could trigger it by a timer, or do a check after each update on each control by calling a function or sth IE:

Option Explicit
Private ChangesMade As Boolean
Private strDummie As String
...
Private Function CheckChangesMade()
If Me.Dirty Then
ChangesMade = True
Me.UndoChangesButton.Visible = True
Else
ChangesMade = False
End If
End Function

Private Sub Test_AfterUpdate()
If ChangesMade = False Then
strDummie = CheckChangesMade()
End If
End Sub

then call that function with AfterUpdate() at each field you got. (I require in this code that you have set the UndoChangesButton.Visible = False as default in the form)
 
thanx - the first option is the one that works well enough for me, but i'll keep it in mind if it needs that little bit extra
 
umm.. you should put that in the onDirty event procedure of the form.

Code:
Private Sub Form_Dirty(Cancel as Integer)
   btnUndoChanges.visible = true
Code:
' I recommend btnUndoChanges.enabled = true
Code:
End Sub


BTW - it's recommended in style that instead of making something "visible" or "invisible" you make it disabled or enabled. It's less of a shock for the end-user when it's there/not there.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top