how to run a module?

ariansman

Registered User.
Local time
Yesterday, 22:10
Joined
Apr 3, 2012
Messages
157
I have made a module, named module1 whose function is to make table1 on which a query1 will be built.
1-What code shall I write in a bottom to run module?
2-Can I make the whole process by one bottom? I mean can I get the final query by just one click, or do I have to run the module to first have the table in hand and then run the query over the table?
Thank you
 
1-What code shall I write in a bottom to run module?

VBA Modules by themselves will not just magically run. A Form could have a Button control on it, and the Button Click event could be defined to call a Function / Subroutine in a VBA Module.

Or you could create an "autoexec" Macro to call a Function / Subroutine in a VBA Module when the database is opened.

2-Can I make the whole process by one bottom?

Say again?

I mean can I get the final query by just one click, or do I have to run the module to first have the table in hand and then run the query over the table?

What are you trying to accomplish, then suggestions for how to accomplish that which you are trying to accomplish may come... not the other way round.
 
VBA Modules by themselves will not just magically run. A Form could have a Button control on it, and the Button Click event could be defined to call a Function / Subroutine in a VBA Module.
in fact my question is that how can i define the Button Click even to call a Function/ Subroutine? what shall i write there?



Say again?

What are you trying to accomplish, then suggestions for how to accomplish that which you are trying to accomplish may come... not the other way round.

the module will compile a table on which a final query will be made. the final query is what i want. shall i provide the module and other information?
thank you
 
in fact my question is that how can i define the Button Click even to call a Function/ Subroutine? what shall i write there?

You can do one of the following:

1) Wire the button click even to =mySubroutineNameInTheVBAModule and fire the VBA Module subroutine that way
2) You can write a small button click subroutine on the Form Module that calls the code in the VBA module. Doing that you would from the Form editor in edit mode, clicked on the button, events, click event, [...] to link over to the VBA editor to fill in code for the event Access wires form the Form control to the VBA editor.
 
thank you all guys for your time, it is now working :)
 
and, one more question,
now, when i push a button, a module is run that puts data into a table ( table1)
i also want to make a query to be created on table1. can i also add a code to the same button to make both functions? i mean put the data into the table1 firstly and then run the query.
 
Sure, but Access is asynchronous, which is to say, if given a series of commands, it starts to execute one, moves on to the next one and starts executing it, and so forth. It doesn't wait for the first command to be completed before starting the second one, and this can cause timing problems.

I'd put the DoEvents command between the two pieces of code. DoEvents will return control to Windows, allowing your Table-creating code to complete running before starting to run the Query-creating code.

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom