Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do I execute a module in Access 2007

Posted on 2009-05-06
9
Medium Priority
?
1,892 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 31

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 31

Accepted Solution

by:
hnasr earned 1000 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 1000 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 31

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 31

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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

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
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

705 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