View Full Version : calling module in every form


aqif
10-09-2001, 05:44 PM
Hi http://www.access-programmers.co.uk/ubb/smile.gif

I'm trying to build a module as :

Public Function CheckVal()

If MsgBox("You are changing the value of a field which is reffered in other information forms, are you aure?", vbYesNo) = vbNo Then
Me.ActiveControl = Me.ActiveControl.OldValue
End If

End Function

What I want to do is that on every text box of different forms I'll write like

AfterUpdate: =CheckVal()

When I put the same code within the form code section it executes OK, but because I have about 20+ forms so I want to build a module and then just call it whereever I want to call. I know I m missing smthng but can't seem to figure it out http://www.access-programmers.co.uk/ubb/wink.gif

Cheers!
Aqif

Pat Hartman
10-09-2001, 08:26 PM
You cannot use the "Me." object reference outside of a form or report. It has no meaning in a standard code module. You will have to pass the control object to the function as you call it -

AfterUpdate: =CheckVal(Me.ActiveControl)

Public Function CheckVal(PassedCntl As Control)

aqif
10-09-2001, 09:55 PM
Hi http://www.access-programmers.co.uk/ubb/smile.gif

I tried ur suggestion but it is not working at the moment...maybe i m doing some mistake because it writes smthg like

=CheckVal([Me].[ActiveControl])

but its not working http://www.access-programmers.co.uk/ubb/frown.gif can u give a little more detail please

Cheers!
Aqif