public sub - accessible within all modules in a project

  • Thread starter Thread starter Kim
  • Start date Start date
K

Kim

I am fairly new to working with access.
I am trying to not replicate code.

I want to create a procedure that I can use on all forms within my project.

I created a public sub and thought that this would allow me to use this
procedure anywhere within my project.
but if I call it in a module where the procedure was not created- i get an
error

How can I do this? It seems very simple but for some reason I am missing
something.

Thank you in advance.
Kim
 
Kim said:
I am fairly new to working with access.
I am trying to not replicate code.

I want to create a procedure that I can use on all forms within my project.

I created a public sub and thought that this would allow me to use this
procedure anywhere within my project.
but if I call it in a module where the procedure was not created- i get an
error

How can I do this? It seems very simple but for some reason I am missing
something.

Thank you in advance.
Kim

Presumably you have created the procedure within a form's module. A form's
module is a class module, which means that any public procedure it contains
is in fact a method of the form. What you need to do instead is to create a
new plain-vanilla VBA module and put the procedure in that.
 
Brian,
yes that is exactly what I did.
I've created a ne module and moved the code into that module - and now I
can access it from any form.
thank you,.

Kim
 
Back
Top