call functions in another module

1) Sub main()
2) Call mod1.fn1
3) Call mod1.fn2
4) End Sub
this function which is in mod2 calls only function 1 but not function 2.

Sponsored Links:

Related Topics

Class module vs regular module
Trying to figure out the difference between these two items. still VBA shaky and not sure which to use to call functions from.


Function in Report is repeating itself?
I call some functions from a report but this report seems to have an issue; It runs all functions in correct order, twice.

Is there anyone who can tell me why it is doing this and how I can prevent it?

The functions are public and are being called from a common module.


Where to define VBA Functions?
Where do I define a user-defined VBA functions so that I can call them in the query?

Here is the problem. I am defining a VBA functions called DateDiffW which calculates the number of weekdays (i.e. excludes sat and sun) between 2 dates.

In access 2007, under the "create" tab I clicked "macro" -> "module". Then I defined the function there, starting with:

Function DateDiffW(BegDate, EndDate)

I then saved the module.

In the query, when I call the DateDiffW function I get the error:

"Undefined Function 'DateDiffW' in expression


How to call module using commandline
I am using access 2000 and OS is XP. how to call module using command line. that's I have to invoke the module exclusively.


Calling Subs/Functions
What is the difference between using Call and not using call? I've seen before that it says 'expected equals' when running a sub without "Call", but a sub doesn't equal anything.

Also, what does it matter if you enclose a sub or functions parameters with parenthesis


Defining Global Variables
I want to define, not just declare, a global string array for use in all my subs and functions in my module.

I know how to define a global function, but I can not call this function in the same way I could call an array.

I could use a class, but I want all the code to be in the same standard module.

All I want to do is something like:

Global StringArray() As String

StringArray(1) = "First String"
StringArray(2) = "Second String"

etc

And be able to access the members of the array elsewhere


VBA - Code structure
Im learning vb in order to be able to add some functionality to my db and forms.

I got experience from java and c and im trying to figure out how you structure and organize ur code in vba and what the similarities are.

When programming in e.g. java you have ur classes and methods where u add ur functions and whatever u wanna do. And then u have ur main function from where u call all the methods etc.

In VB, what ive understood, u got models and all these commands which been added to various buttons on forms reports etc.

Can these models be seen as the corresponding classes in java where u store all ur functions etc?

When looking in VB from some already made database u can see all the Class Objects where commands have been added to forms etc. In addition u also have ur modules below. How do these work together? When do I need a module?

If I have a form performing different tasks i.e a collection of class objects - why would I for example need a module


Creating Macro from Module
to Rural Guy, I've been able to get the coding to copy one database to another.

Now that has been accomplished, I need to create a macro that calls to the module that I have created.

The module I've created that copys the table to another database is called Archive Current Server List.

I've been looking at the "RunCode" option but I have no idea how to call to the coding in the module to run it.

If I use the "Open Module" option, then it opens the module and you need to run the module from there.

I need to limit users from getting in this area as you know people could inadvertanly screw up the coding


How to call a query in my vba module
I have a query called "ClearTable Query" which clears the contents of a table, how do I call this in my vba module thingy? (i.e. the bit where you write the whole
sub myfunction
.
end sub

also, when I run the query on its own, it asks me for confirmation, how do I fix it so it just does the query without asking?


Modules, Procedures, and Functions
A module is a file that holds code or pieces of code that belong either to a form, a report, or is simply considered as an independent unit of code. This independence means that a unit may also not belong to a particular form or report. Each form or report has a (separate) module.
Topics: Modules, Sub Procedures, Functions, Accessories for Programming, Techniques of Passing Arguments, Programmer-Defined Data Types, Introduction to Built-In Functions and Procedures,
Message and Input Boxes.


Better organization of functions and procedures: form modules vs standard modules
I need a good resource for better understanding some of the subtleties of writing better/faster/ more efficient VBA code.

Can someone tell me what the pros and cons are of moving functions and/or procedures to standard modules instead of the form module where it is used? I can see where it's beneficial to have a single procedure, such as Allen Browne's "DoMouseWheel" to enable the mouse wheel to scroll through records on many different forms, but is there a speed advantage in terms of the formloading faster if the functions are stored in a standard module? If so, what's the disadvantage? I've been writing VBA code for several years, and some of my forms have rather long codes,but I don't know when it's proper to move some of that to a standard module.

I've also seen/borrowed modules where a function calls several sub functions to accomplish a task rather than having of the code under one function. I don't understand the advantages ofthis, either,


How do i run a module in Access?
I am using Access 2010 and am running a query to search for a specific substring within a field to return the records that contain only that substring. I have created a module that would be able to test for the substring and return a value of 1 or 0 depending on if it was found but I do not know how to integrate that module into the query.

is there a way in SQL view that ican call the module, and would I have to pass values to it from the table to run properly?


Hiding code
I have created specific functions (Public () as.) whose code is stored in table fields. When some of these specific functions are needed, I read the table content,dynamically create a new module, put the function code within, make an Eval() to get a result, and erase the dynamically created module.

My problem is that the VBA editor window is launched. Is there a way to prevent its display (by code or something else)?


Where Can I Get Info On Modules
I would like to know how to create a public module and how can I call that module.
Can anyone suggest me a website where I can learn about modules preferably with video's


Call to goto specified module and open to specified function/sub
Looking for the capability to go to (from a highlighted treeview control) specified module and display specified function/sub.

All suggestions appreciated.

Best wishes - Bob


Custom function inside SQL query (Access VBA)
I'm trying to use a custom (user-defined) function inside an SQL query. When the function is in a normal module, the code works fine, but when the function is in a Class Module, Note: I have made sure the Function is Public in the Class Module. The Routine that creates and executes the SQL command is in the Class Module.

Is it forbidden to call a function residing in a Class Module from an SQL query, or am I missing something?


Useful Report Functions
Common Functions that you can use in Report Header or Footer Sections, while designing Reports, are given below. Copy and Paste the VB Code into a Global Module of your database and save it.


using functions in reports
I want to use some functions I have in a module for data that should be displayed in a report, how should I do that?

for example control source of a text box in a report is Code, but I want Code^2/10 ( the actual function is much more lengthy and calls some other functions) where should I apply that? I tried set the me.Code.someproperties = function(me.code.someprop) in the on activate event but I got an error for every properties I checked.


Hiding code
I am working an a complex database.

I have created specific functions (Public <function name>() as.) whose code is stored in table fields. When some of these specific functions are needed, I read the table content, dynamically create a new module, put the function code within, make an Eval(<function name>) to get a result, and erase the dynamically created module.

My problem is that the VBA editor window is launched. Is there a way to prevent its display (by code or something else


Hiding Code
I am working an a complex database.

I have created specific functions (Public <function name>() as.) whose code is stored in table fields. When some of these specific functions are needed, I read the table content, dynamically create a new module, put the function code within, make an Eval(<function name>) to get a result, and erase the dynamically created module.

My problem is that the VBA editor window is launched. Is there a way to prevent its display (by code or something else