Solved

How do I execute a module in Access 2007

Posted on 2009-05-06
9
1,890 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

Author Comment

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

Cheers
0
 
LVL 85

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

617 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