Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old June 30th, 2009, 03:40 PM
needhelp09 needhelp09 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 6 needhelp09 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 7 m 57 sec
Reputation Power: 0
Macros - New to access; runmacro action not working

I created a simple macro to type message using Msgbox "test" and tried to run it using runmacro. But, nothing happens. No errors or messages. Please help. Thanks.

Reply With Quote
  #2  
Old June 30th, 2009, 03:54 PM
rpeare rpeare is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jan 2008
Posts: 1,093 rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 23 h 52 m 46 sec
Reputation Power: 227
Depending on the version of access you're running you will have to enable macros. For access 2003 you would do this:

TOOLS>MACROS>SECURITY

You are probably set to a medium or high security which prevents almost everything from running.

For Access 2007 it's slightly different and I can't remember it off the top of my head.
__________________
----------------
If we've helped you and you have solved your problem please post that it's been resolved so we know! The suspense kills me!

Reply With Quote
  #3  
Old June 30th, 2009, 07:17 PM
needhelp09 needhelp09 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 6 needhelp09 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 7 m 57 sec
Reputation Power: 0
Thank you for the suggestion. No, that wasn't it. I already had the security level in Access 2007 set to enable all Macros. Any other ideas?

Reply With Quote
  #4  
Old June 30th, 2009, 11:17 PM
rpeare rpeare is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jan 2008
Posts: 1,093 rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 23 h 52 m 46 sec
Reputation Power: 227
Did you save the macro before trying to run it. Usually access forces you to save before you can run but that may be turned off in your case.

Your macro has 1 line only that says MsgBox
in the action arguments (lower left of the screen in anything below access 2007) there are four lines. The first one says test in it?

Reply With Quote
  #5  
Old July 2nd, 2009, 10:39 AM
needhelp09 needhelp09 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 6 needhelp09 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 7 m 57 sec
Reputation Power: 0
This is how I created and stored my macro (similar to Excel which I am more familiar with):
On the Form View, I hit Alt+F11 and typed the following code:

Option Compare Database
Option Explicit
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''
Private Sub cmdOpenExcelFile()
MsgBox "Test"
End Sub


(As you may have guessed from the name of the macro the purpose of the macro eventually is to open an excel file while in the Access program. For the present, I just wanted it to type a message through a MsgBox command.)


Then, I wanted to activate this macro using a command button. So, I created a button and tried to run the macro by clicking on properties and event. But nothing happens (after saving, properly exiting the design mode and entering the form view).
Also, tried to enter the Macro mode directly by clicking on the Create>>Macro>>Action (Runmacro)>>Argument buttons, and again nothing happens. Incidentally, by the same approach if I picked message box action instead of the runmacro, the message box works properly.

Hope this clarifies some. Thanks for your help.

Reply With Quote
  #6  
Old July 2nd, 2009, 10:43 AM
rpeare rpeare is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jan 2008
Posts: 1,093 rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 23 h 52 m 46 sec
Reputation Power: 227
That's not a macro, that's VB script.

What you want to do is create your button FIRST then in your form design view click on the button, bring up the properties and in the ON CLICK event you want to put in your

msgbox "test"

the code surrounding it will be something like

Private Sub cmdOpenExcelFile_Click()
MsgBox "Test"
End Sub

Reply With Quote
  #7  
Old July 2nd, 2009, 11:11 AM
needhelp09 needhelp09 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 6 needhelp09 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 7 m 57 sec
Reputation Power: 0
Thank you for your prompt response. I greatly appreciate it. The question I have is where is this code located (e.g., Alt F11 does not show this code in Form_Form1) so that I can replace the MsgBox statement with a set of statements to perform other tasks (namely, as I indicated before, to open an excel file).
Thanks as always.

Reply With Quote
  #8  
Old July 2nd, 2009, 11:58 AM
rpeare rpeare is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jan 2008
Posts: 1,093 rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level)rpeare User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 23 h 52 m 46 sec
Reputation Power: 227
Create a form
put a button on the form called Cmd_001
right click on the button Cmd_001 and click PROPERTIES
Scroll down to the ON CLICK property
Click on the row containing the label ON CLICK
Click on the three button labeled ...
Select CODE BUILDER
The code builder will supply the sub opening and closing

Code:
Private Sub Cmd_001_Click()

End Sub


Type MSGBOX "TEST" between the opening and ending of the command

Code:
Private Sub Cmd_001_Click()

msgbox "TEST"

End Sub


close the VBScript window
open the form in form view
click on the button

the message box should pop up.

not sure how much clearer it can be.

If you then want to modify what the button does you just go back to the design view go to the properties of the button to the ON CLICK event and modify the code.

Reply With Quote
  #9  
Old July 2nd, 2009, 12:27 PM
don94403's Avatar
don94403 don94403 is offline
Contributing User
Click here for more information.
 
Join Date: Jan 2007
Location: Northern California
Posts: 2,848 don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Weeks 18 h 41 m 42 sec
Reputation Power: 562
~rpeare has given you step-by-step instructions for creating a VBA Event Procedure, which as he said is completely different from a Macro. I just thought I would add a little background for you. What you were attempting to do (and calling a Macro, which again is something entirely different) was a procedure in a Module, which you can reach by opening the Modules tab in the Database Window. But those are only used for procedures and functions which are NOT related to actions based on some event on a Form. Such actions as clicking on a button are done either with Macros (which most of us never use because of their limited functionality) or Event Procedures, which is what ~rpeare showed you how to do. Event Procedures (sometimes called Class Functions) are stored as part of the Form they are called from, and can be reached through the properties sheet of the component or part of the Form that calls them. You can also open all the VBA code for a Form or Report by pressing Alt+F11.
__________________
Experience is the thing you have left when everything else is gone.

Reply With Quote
  #10  
Old July 2nd, 2009, 03:35 PM
needhelp09 needhelp09 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 6 needhelp09 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 7 m 57 sec
Reputation Power: 0
It works!! I can't thank you enough.

By way of feedback,
1. I need to educate myself on the terminology better: Macro vs. VB script
2. I had the VB script prepared first and then tried to assign that to a button I created; the system is not meant to do that. I wonder why.
3. I also did not go into Code Builder (saw only Macro Builder).

Thanks again.

Reply With Quote
  #11  
Old July 2nd, 2009, 04:11 PM
needhelp09 needhelp09 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 6 needhelp09 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 7 m 57 sec
Reputation Power: 0
Thanks for the input. I will work on the semantics. You had a lot of topics in your message. I will try to learn about them one by one.

Reply With Quote
  #12  
Old July 2nd, 2009, 11:56 PM
don94403's Avatar
don94403 don94403 is offline
Contributing User
Click here for more information.
 
Join Date: Jan 2007
Location: Northern California
Posts: 2,848 don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Weeks 18 h 41 m 42 sec
Reputation Power: 562
Not meaning to pile on, but there's an important difference between VB (Visual Basic) scripts and VBA (Visual Basic for Applications). A lot of the syntax is the same, but VBA is very specific to Microsoft Office Applications, while VB is a generalized scripting language.

Yes, it will really improve your ability to get help in forums and elsewhere if you have the terminology correct. This is a terribly detailed and finicky business, and accurate understanding is possible only when everyone understands what the others are referring to at every point.

You'll learn, with more experience.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > Macros - New to access; runmacro action not working


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
Stay green...Green IT