Dim frmLoop As Form
Dim ctrLoop As Control
For Each frmLoop In Forms
For Each ctrLoop In frmLoop
Me.frmLoop.Controls.ctrLoop.OnUndo = "myProcedure"
Next ctrLoop
Next frmLoop
Am I on the right track? I know my syntax is bad. That's why it's not
working? Thanks for any help
Dim ctlSubform As Control
Dim ctrLoop As Control
For Each ctlSubform In Me.Controls
If TypeOf ctlSubform Is Subform Then
For Each ctrLoop In ctlSubform.Form.Controls
' ctrLoop.OnUndo = "myProcedure"
Next ctrLoop
End If
Next frmLoop
However, I'm not aware of an Undo event (I only have Access 97 on this
machine, and it definitely doesn't have that event) If there is an Undo
event, the property would likely be called Undo, not OnUndo, and not every
control would have one (for example, since you can't type in a label or
line, there wouldn't be an Undo event for them). What you might want to do
is add a function like the following:
Function HasEvent(ControlObject As Control, EventName As String) As Boolean
On Error Resume Next
Dim strCurrProc As String
strCurrProc = ControlObject.Properties(EventName)
HasEvent = (Err.Number = 0)
End Function
You could then use
Dim ctlSubform As Control
Dim ctrLoop As Control
For Each ctlSubform In Me.Controls
If TypeOf ctlSubform Is Subform Then
For Each ctrLoop In ctlSubform.Form.Controls
If HasEvent(ctlLoop, "Undo") Then
ctrLoop.Undo = "myProcedure"
End If
Next ctrLoop
End If
Next frmLoop
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"NasaDBGuy" <Nasa...@discussions.microsoft.com> wrote in message
news:955CD9DC-291A-4FD7...@microsoft.com...
As an FYI, there is an Undo event in A2K3 (don't know about 2002 as I don't
have that one) and it isn't in 2000.
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
__________________________________
If my post was helpful to you, please rate the post.
I can test for the type of control, so I don't have to test to see if it has
that particular event. Instead of using your HasEvent() procedure I just use
if typeOf ctlText is TextBox Then
and from what I've gathered, undo is the event, OnUndo is the property of
the control that allows me to assign a procedure to that event.
Thanks again for your help.
ctrLoop.OnUndo = "=MyProcedure()"
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"NasaDBGuy" <Nasa...@discussions.microsoft.com> wrote in message
news:73228A1F-EBA7-4479...@microsoft.com...