Public Function to do a Me.Undo when called from a Form Control? (1 Viewer)

Steve C

Registered User.
Local time
Today, 07:12
Joined
Jun 4, 2012
Messages
120
I want to call MyPublicFunction from a Control Before Update event,

MyPublicFunction()
If MyGlobalBoolean True then
MsgBox “Some message.”
Me.undo
End If

Of course, MyPublicFunction doesn’t know the “Me” in Me.Undo.

How can I pass the "Me" to MyPublicFunction so it knows what to undo?

Of course, a Private Function will work but it would have to be repeated many times and so would be tricky if changes are needed in the future.

Thank you very much

Steve C
 
Last edited:

JHB

Have been here a while
Local time
Today, 16:12
Joined
Jun 17, 2012
Messages
7,732
Call it with the Me.
Code:
  Call MyPublicFunction(Me)
Code:
Public Function MyPublicFunction(Theform As Form)
  If MyGlobalBoolean True then
    MsgBox “Some message.”
    Theform.Undo
  End If
End Function
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:12
Joined
Aug 30, 2003
Messages
36,130
Another option might be using ActiveForm.
 

Steve C

Registered User.
Local time
Today, 07:12
Joined
Jun 4, 2012
Messages
120
Thank you very much JHB & pbaldy.

two elegant solutions which I would not have figured out on my own - thanks again.

Steve C
 

Users who are viewing this thread

Top Bottom