Module help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a module that I got to work for one field by clicking the Code builder
button in the After update property event in a field. It works as expected.
Now I want to convert that code to a sub that I can call for other fields.
How do I do that?

Thanks.
 
Generically...

Open the VBA editor for that control (by the way, a button can Click, but
how can it Update?)

Find the code. Change the name of the procedure. Change any references to
the original control to a generic reference, or modify the code to "get" the
name of the active control.

To each control you wish to have use the new procedure, add something like:

Call YourNewProcedure()

to the control's AfterUpdate event (assuming this is something that runs
AfterUpdate).

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
 
Thanks. Do I put it on the After Update line in the property listing?
Because when I do that, it says it can't find the macro. When I put it in
the code it says "method or data member not found". I changed the reference
to the field to Me. Is that right?
 
If you want the procedure to run on a control named X, you'll either have to
pass the name of the control to the procedure (so it knows what to run on),
or you'll have to have the procedure check to see which control is "active"
(check Access HELP for ActiveControl). Changing the reference to "Me." only
tells Access to use the form in which it finds itself.

I'm not clear how "macro" came into this. I thought we were discussing
code...

Which event you add the call into depends when you want the procedure to
trigger. I didn't notice that in your previous post...

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
 
Back
Top