Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / July 2006

Tip: Looking for answers? Try searching our database.

Global Function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ray C - 15 Jul 2006 09:10 GMT
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.
Douglas J. Steele - 15 Jul 2006 11:53 GMT
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.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

>I an very new to writing Access code so my appologies for what may seem to
>be
[quoted text clipped - 21 lines]
>
> Thanks for any help.
Ray C - 16 Jul 2006 10:00 GMT
Thank you for the tip douglas, I will give it a try

Regards RayC

> 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
[quoted text clipped - 25 lines]
> >
> > Thanks for any help.
Ray C - 16 Jul 2006 10:30 GMT
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

> I an very new to writing Access code so my appologies for what may seem to be
> a very basic quetion.
[quoted text clipped - 16 lines]
>
> Thanks for any help.
Douglas J. Steele - 16 Jul 2006 12:59 GMT
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.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> Hi Douglas
>
[quoted text clipped - 40 lines]
>>
>> Thanks for any help.
Ray C - 17 Jul 2006 08:39 GMT
Yep, got it to work.

Thanks for your help

RayC

> Since you no longer have TanapaCodeTrap in the code behind the form, Call
> TanapaCodeTrap(Number) should be all you need to use.
[quoted text clipped - 46 lines]
> >>
> >> Thanks for any help.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.