Global Function

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

Guest

I an very new to writing Access code so my appologies for what may seem to be
a very basic quetion.

I have an access Database with a number of "Modules called form a Menu Form.
Each of these modules contains Sub's and Functions. However, I need to check
a String piece of data that is scanned in from a Barcode Reader to see if the
data is acceptable or not. This is done by calling a Function within the
Module where I pass the string Data to it and Parse that string through a
list of Forbiden Serial Numbers. if the input does not match any of the
Forbiden Data, the function returns True and the program continues. If the
Function matches the string with any of the Forbiden Data, the Function
returns False and the program that response accordingly.
My problem is that this Function is required in a number of different
Modules. Is there any way that I could have this Function as a Global
Function and, insted of calling it from within the Module. I could have a
calling routine within every module that requires to use it and just call one
Globaly available Function that would return a True or False.
This way, I would only need to maintain one list of forbidden data.

Thanks for any help.
 
Create a Module (not a Class Module), and put the function there. Assuming
Access 2000 or newer, when you're in the VB Editor (Alt-F11), choose Module
from the Insert menu.
 
Hi Douglas

I tried this and generated a module (module1). I then copied my function
(Called TanapaCodeTrap) into that Module and voided the name of the original
Function by renaming it "TmpTanapaCodeTrap". When I now call that function
from within the main Code I get an error because it can not find
"TanapaCodeTrap".

The original Call to the Function within the main Code is " Call
TanapaCodeTrap(Number)". Do I need to change this to something like "Call
Module1, TanapaCodeTrap(Number)".?

Also, Is there any way to change the name of "Module1" to something more
user friendly?

Thanks RayC
 
Since you no longer have TanapaCodeTrap in the code behind the form, Call
TanapaCodeTrap(Number) should be all you need to use.

To rename a module, look in the Properties window for the Module. The only
property you should see is Name, which you can change.
 
Back
Top