running multiple modules with clicking one button on the form (1 Viewer)

mattaus

Registered User.
Local time
Today, 04:10
Joined
Apr 27, 2009
Messages
35
Hi,

On my form I have a button called 'runall', what would be the correct syntax to insert in my vba once this button is clicked to run all modules, theer are around 6 modules i would like it to run...

I know the synatxt to get it to run 1 module but i am not sure how to tell it to run multiple modules one after another-not at the same time

thanks
 

mattaus

Registered User.
Local time
Today, 04:10
Joined
Apr 27, 2009
Messages
35
I would run the first module using the code below: 'AHP' is the name of my button and 'AHP_ACTIVITY.Test_Reporta1' is in the location and name of the module...


Private Sub AHP_Click()
AHP_ACTIVITY.Test_Reporta1
End Sub
 

Guus2005

AWF VIP
Local time
Today, 13:10
Joined
Jun 26, 2007
Messages
2,641
I am afraid that when you have to run eight different procedures you have to place them under eachother in order to execute them sequentially.

Code:
Private Sub AHP_Click()
    RunAll
End Sub 

private sub RunAll()
    AHP_ACTIVITY.Test_Reporta1
    AHP_ACTIVITY.Test_Reporta2
    AHP_ACTIVITY.Test_Reporta3
    AHP_ACTIVITY.Test_Reporta4
    AHP_ACTIVITY.Test_Reporta5
    AHP_ACTIVITY.Test_Reporta6
    AHP_ACTIVITY.Test_Reporta7
    AHP_ACTIVITY.Test_Reporta8
end sub
HTH:D
 

DCrake

Remembered
Local time
Today, 12:10
Joined
Jun 8, 2005
Messages
8,632
To generalise, you do not run Modules, modules are only containers for functions and sub routines, etc, be they private, public declarations, etc. You acutally need to call the functions held within them.

David
 

mattaus

Registered User.
Local time
Today, 04:10
Joined
Apr 27, 2009
Messages
35
Hi,

Just for anybody else dealing with a smilar problem 'ahp' is the name of the module so the above code did not work, howevver the below code worked without the modules referenced:

Private Sub AHP_Click()
RunAll
End Sub

private sub RunAll()
Test_Reporta1
Test_Reporta2
Test_Reporta3
Test_Reporta4
Test_Reporta5
Test_Reporta6
Test_Reporta7
Test_Reporta8
end sub
 

Guus2005

AWF VIP
Local time
Today, 13:10
Joined
Jun 26, 2007
Messages
2,641
Ah, so that was the problem.

A modulename is a modulename is a modulename and nothing else. It is neither a Class or an Object. It is just used to keep related functions and procedures together.

A module however as part of a form is part of the object "form" and that's a different ballgame.

HTH:D
 

Users who are viewing this thread

Top Bottom