Link to home
Start Free TrialLog in
Avatar of Paul Burrows
Paul BurrowsFlag for New Zealand

asked on

How do I execute a module in Access 2007

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

Avatar of Hamed Nasr
Hamed Nasr
Flag of Oman image

in the immediate window:
x = Rebuild()
Avatar of Paul Burrows

ASKER

Sorry ... .I don't understand what you mean
ASKER CERTIFIED SOLUTION
Avatar of Hamed Nasr
Hamed Nasr
Flag of Oman image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks - I'll give it a go tomorrow when I get to work

Cheers
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Real expert's comment should be:
As hnasr suggested "You can use it through code depending on your project." , add.... or ....
;-)
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
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
" I just wish to click the object in the modules section and have the code execute."

Click at End Function line
Press Ctrl+F8