Solved

How do I execute a module in Access 2007

Posted on 2009-05-06
9
1,879 Views
Last Modified: 2012-06-27
I used to quite like the previous "macro" functionality

However if I have the attached script in Access 2007 how do I execute it without going to the code and clicking "Run"



Function Rebuild()

On Error GoTo Proc_030_Err
 

DoCmd.SetWarnings False
 

    DoCmd.OpenQuery "100 Clear Temp 01 ARSHIP with keys", acViewNormal, acEdit

    DoCmd.OpenQuery "110 ARSHIP with keys", acViewNormal, acEdit

    DoCmd.OpenQuery "300 Clear Temp 03 Sales F2007 on", acViewNormal, acEdit

    DoCmd.OpenQuery "310 Rebuild Temp 03 Sales F2007 on", acViewNormal, acEdit
 

    MsgBox "Tables Rebuilt", vbInformation, "Finished"

    

DoCmd.SetWarnings True
 

Proc_030_Exit:

    Exit Function
 

Proc_030_Err:

    MsgBox Error$

    Resume Proc_030_Exit
 

End Function

Open in new window

0
Comment
Question by:Zarbs
  • 4
  • 4
9 Comments
 
LVL 30

Expert Comment

by:hnasr
ID: 24322307
in the immediate window:
x = Rebuild()
0
 

Author Comment

by:Zarbs
ID: 24323021
Sorry ... .I don't understand what you mean
0
 
LVL 30

Accepted Solution

by:
hnasr earned 250 total points
ID: 24323180
You have a function called Rebuild() in a module
Open the module and a window called immediate shows at the bottom.
If not shown select view menu > Immediate Window
In the immediate window type:
x = Rebuild() to run that function

You can use it through code depending on your project.
0
 

Author Comment

by:Zarbs
ID: 24323193
Thanks - I'll give it a go tomorrow when I get to work

Cheers
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
ID: 24323571
Or add a button to a Form, the use the Click event of that button to run your code:

Sub MyButton_Click()
  Rebuild
End Sub

Or add a Macro with the RunCode action, with the argument set to "Rebuild()"
0
 
LVL 30

Expert Comment

by:hnasr
ID: 24326593
Real expert's comment should be:
As hnasr suggested "You can use it through code depending on your project." , add.... or ....
;-)
0
 

Author Comment

by:Zarbs
ID: 24330356
I must have missed something.

LSMConsulting - I don't really want to have a form .... I just wish to click the object in the modules section and have the code execute.   This is what I would have done in access 2003 and earlier when a macro would run

hnasr - what you suggested did not seem to work.  See atached screen as to what I did
8-05-2009-8-31-34-a.m..jpg
0
 

Author Comment

by:Zarbs
ID: 24332811
I really did miss something in that I discovered you can still create macros in Access 2007 .... which allowed me to run my code as I wanted by running that piece of code

Thanks to you both
0
 
LVL 30

Expert Comment

by:hnasr
ID: 24333001
" I just wish to click the object in the modules section and have the code execute."

Click at End Function line
Press Ctrl+F8
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

29 Experts available now in Live!

Get 1:1 Help Now