Results 1 to 10 of 10
  1. #1
    Soule is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Dec 2011
    Posts
    58

    Why Does Macros Dialog Pop-Up When I Try To Run Code In VB Editor?

    I'm trying to see if the following frustratingly simple code runs to open Outlook:



    Private Sub A1S1_Form_Re_send_Welcome_E_Mail_Only_Button_Click ()
    Dim objOutlook As Outlook.Application
    Set objOutlook = CreateObject("Outlook.Application")
    End Sub

    But when I hit the "Run" arrow button in the toolbar, the "Macros" dialog box pops up (with no entries). Why is this happening and should I be entering something in it?

    The button that this code is for is an On-Click "Event Procedure" event. I thought that in 2007, that was code and not a macro.

    Why can't I do a simple step-compile in the editor, Microsoft?!

    Much thanks ahead of time for any advice,
    Frank
    Windows XP, Access 2007, .accdb file

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    It's because the Sub not in a general module. VBA can't find it so prompts with the Macro dialog. You can call form subs from immediate window by referencing the form.

    Form_formname.A1S1_Form_Re_send_Welcome_E_Mail_Onl y_Button_Click
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Soule is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Dec 2011
    Posts
    58
    Quote Originally Posted by June7 View Post
    It's because the Sub not in a general module. VBA can't find it so prompts with the Macro dialog. You can call form subs from immediate window by referencing the form.

    Form_formname.A1S1_Form_Re_send_Welcome_E_Mail_Onl y_Button_Click
    Thanks, June! I cut/pasted the code into its own module and named the module to "Re-Send Welcome E-Mail Only Button" for clarity. The code building area in the main form is now blank, except for the declarations.

    Is there any problem with the way it is now?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Okay, you can have code in a general module. How do plan to run it? Always by manual execution? Or have the button click call the sub?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Soule is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Dec 2011
    Posts
    58
    Quote Originally Posted by June7 View Post
    Okay, you can have code in a general module. How do plan to run it? Always by manual execution? Or have the button click call the sub?
    What is the difference?

    I want it to run when the user clicks on a form button...

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    That is fine unless you need to refer to controls on form for some data. If the code were behind the form could use Me.control name. With code in general module will have to pass values as arguments of the sub or have sub get the values by reference to the form: Form_formname.controlname.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Soule is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Dec 2011
    Posts
    58
    Quote Originally Posted by June7 View Post
    Okay, you can have code in a general module. How do plan to run it? Always by manual execution? Or have the button click call the sub?
    What is the difference between manual execution and having the button click call the sub? Aren't they the same thing?

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    By manual I mean position the cursor in the procedure and click Run. I have a few maintenance/utility procedures only I run, no need to make available to other uses and I never bothered to build accessibility in forms. But you have button dedicated to this so all good.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    Soule is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Dec 2011
    Posts
    58

    Standard Module Code Into Form Main Class Module

    Thanks, June -

    I'm going to take your advice and move my on call button code back into the form's main class module so I can use the "Me" function to call data out of controls (which I do actually need to do) instead of always having to type out "[]![]" references in my code. The "Me" code is simpler and I want to keep my code simple.

    If the "Macros" dialog box opens while I am compiling in the VB editor, I'll just have to close it every time. No big deal.

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    The macro dialog box should not appear if you test the code by executing it from the button click.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Basic help with 2010 code editor please
    By Tablerone in forum Programming
    Replies: 2
    Last Post: 10-02-2011, 06:01 PM
  2. MsgBox in VBA Editor not popping up
    By KrisDdb in forum Access
    Replies: 2
    Last Post: 09-16-2011, 01:58 PM
  3. HTML Editor
    By mystifier in forum Forms
    Replies: 3
    Last Post: 11-11-2010, 05:51 AM
  4. Text editor
    By smiles_chicago in forum Forms
    Replies: 0
    Last Post: 10-21-2008, 12:38 PM
  5. Replies: 0
    Last Post: 04-04-2008, 03:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums