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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Undo - such a simple thing?

Status
Not open for further replies.

richardii

Programmer
Jan 8, 2001
104
GB
I'm having no luck writing an Undo button for a subform. The subform is paged so I want to put one button on the main form that does the Undo. I know I have to set the focus to the subform for this to work. Setting the focus to the subform and then .undo results in the BeforedelConfirm event being called!!

So I thought I'd try this (from the Access Help). But the ctl should surely read ctlTextbox.OldValue ? When I change it to ctlTextBox the .OldValue is the same as the .Value! The help talks about writing your own Undo, but how?!

Sub btnUndo_Click()
Dim ctlTextbox As Control
For Each ctlTextbox in Me.Controls
If ctlTextbox.ControlType = acTextBox Then
ctlTextbox.Value = ctl.OldValue
End If
Next ctlTextbox
End Sub





 
Well, if you were going to write you own undo, you would just have an array running around in the code that held the values of the previous entries...

I suppose that in it's simplest form, it would only be a single variable -- the more steps you wanted to be able to undo, the more elements to an array you would add.

Clicking the undo button would just go look and see what value was on top, and plug it back into the field.

I don't know about using the .undo function, but if you could get that to work, I'm sure it would easier.

good luck! :)
Paul Prewett
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top