none
2007 embedded macros

    Question

  • I am a little dismayed at this feature.  In 2007.accdb I have gone to Access Options and selected the check box 'Always use event procedure' ....but yet when going to add a bit of VB to a command button - - find that it is an embedded macro.

    The option was checked at the beginning of the design of the db so am surprise to find this on this button.

    Would like to add some simple If/then vb to the OnClick event of this command button - not specifically related to what the command is doing - but just doing a compare of some text box controls values and then moving the focus to a control depending on those values....stuff like this is usually a breeze and I feel a bit stymied.

    Would welcome some guidance on this.

     

    Friday, July 02, 2010 3:00 AM

Answers

  • Remember the song? "Don't Worry...,  Be Happy !...."

    No need to be frustrated. Get a little experience and you will get used to things as they are.

    You can do a lot with macros, especially in Access 2010. VBA code window gives you more options and flexibility, so professional developers usually write code. Embedded macros considered to be "safe".

    If you are willing to learn about macros in 2007 - here is a reference http://msdn.microsoft.com/en-us/library/bb149142(v=office.12).aspx, and for 2010 version : http://blogs.msdn.com/b/access/archive/2009/07/28/meet-the-access-2010-macro-designer.aspx

    Here is one of the views about macros vs VBA http://www.databasedev.co.uk/macros-in-access.html.

    Nadia

    • Proposed as answer by NadiaSz Friday, July 02, 2010 11:23 PM
    • Marked as answer by Tim Li Friday, July 09, 2010 8:45 AM
    Friday, July 02, 2010 10:34 PM
  • Thanks for the reply, and for the links.

    I really would still like to be clear on this point of the macro vs vba in event:  per my first post I had checked for "'Always use event procedure'  - and yet receive the embedded macro on a command button (using the wizard).  To which I was told using wizard always results in an embedded macro.

    Thus if one wishes to remain vba centric - - then we need to keep a little library on the side for basic tasks i.e. open form, etc....and plug these in ourselves now?

    ....or turn off wizards?   


    This is only true for ACCDB format databases.  MDBs still create VBA code in wizards.  You could develop in MDB format and then convert to ACCDB if you really have to.  Another option is to keep a scratch MDB around where you can use the wizards to create code and paste into your application.
    • Marked as answer by Tim Li Friday, July 09, 2010 8:45 AM
    Tuesday, July 06, 2010 3:06 PM

All replies

  • Hello,

    If you use Control Wizard - it always generates a macro.

    You can overwrite Embedded macro by selecting "Event Procedure" from event combobox on the Property sheet, or just click on the ... button on the event line to go to event's code stub.

    Nadia

    • Proposed as answer by NadiaSz Friday, July 02, 2010 11:23 PM
    • Edited by NadiaSz Tuesday, July 06, 2010 3:06 PM typo
    Friday, July 02, 2010 3:43 AM
  • first - thanks for the reply.

    ' you use Control Wizard - it always generates a macro.'

    ** ah ok - that answers that question - - but it doesn't seem consistent with the checkmark option to always use Event;  but it is what it is I suppose....

    You can overwrite Embedded macro by selecting "Event Procedure" from event combobox on the Propeerty sheet

    ** thanks for that input - - regrettably changing from Embedded Macro to Event on this event also erases the vb of the command event so it is just a blank sub with no code at all.....

     or just click on the ... button on the event line to go to event's code stub.

    *** no the ...      when clicked  will open to the macro (if it is listed as an Embedded Macro) it does not open to vb

    So I remain frustrated - partially because I can not follow MS's logic to this new approach.  The embedded macro surely is not more accessible to newbies.  No one can convince me that it is.  And it clearly is an obstacle for veteran developers.  And then there is the inconsistency of the option selection to 'always use Events' that in fact does not do what it promises. (I mean the word 'always' does imply 'always' - and not just if one doesn't use the button wizard)

    If working within the Embedded Macro structure is better, easier, etc.  - I don't see it, but am always willing to learn.  I'm trying not to be resistant to change.  But on this topic I just do not follow why we are forced into the world of embedded macros (if we use wizards).  Or not to use wizards I suppose and keep a personal library of vba code chunks to copy/paste into events....

    If someone can enlighten me with info on these embedded macro, why they are now being emphasized, and their advantages, and such - - I definitely would welcome that input.  and more specifically to this post; if I am in a command button embedded macro and wish to then if/then compare to other control values, after which then set focus to another control depending on the results - can this easily be accomplished within an embedded macro? plz instruct syntax...I'm certainly willing to learn if this is how MS wants us to do things....

     

    Friday, July 02, 2010 1:26 PM
  • Remember the song? "Don't Worry...,  Be Happy !...."

    No need to be frustrated. Get a little experience and you will get used to things as they are.

    You can do a lot with macros, especially in Access 2010. VBA code window gives you more options and flexibility, so professional developers usually write code. Embedded macros considered to be "safe".

    If you are willing to learn about macros in 2007 - here is a reference http://msdn.microsoft.com/en-us/library/bb149142(v=office.12).aspx, and for 2010 version : http://blogs.msdn.com/b/access/archive/2009/07/28/meet-the-access-2010-macro-designer.aspx

    Here is one of the views about macros vs VBA http://www.databasedev.co.uk/macros-in-access.html.

    Nadia

    • Proposed as answer by NadiaSz Friday, July 02, 2010 11:23 PM
    • Marked as answer by Tim Li Friday, July 09, 2010 8:45 AM
    Friday, July 02, 2010 10:34 PM
  • Thanks for the reply, and for the links.

    I really would still like to be clear on this point of the macro vs vba in event:  per my first post I had checked for "'Always use event procedure'  - and yet receive the embedded macro on a command button (using the wizard).  To which I was told using wizard always results in an embedded macro.

    Thus if one wishes to remain vba centric - - then we need to keep a little library on the side for basic tasks i.e. open form, etc....and plug these in ourselves now?

    ....or turn off wizards?   

    Tuesday, July 06, 2010 12:17 PM
  • Thanks for the reply, and for the links.

    I really would still like to be clear on this point of the macro vs vba in event:  per my first post I had checked for "'Always use event procedure'  - and yet receive the embedded macro on a command button (using the wizard).  To which I was told using wizard always results in an embedded macro.

    Thus if one wishes to remain vba centric - - then we need to keep a little library on the side for basic tasks i.e. open form, etc....and plug these in ourselves now?

    ....or turn off wizards?   


    This is only true for ACCDB format databases.  MDBs still create VBA code in wizards.  You could develop in MDB format and then convert to ACCDB if you really have to.  Another option is to keep a scratch MDB around where you can use the wizards to create code and paste into your application.
    • Marked as answer by Tim Li Friday, July 09, 2010 8:45 AM
    Tuesday, July 06, 2010 3:06 PM
  • Yes, your understanding is correct. I see your point that you wanted to be productive and have the code generated by the wizard. Unfortunately, this functionality is not there.

    If you want to learn more how macro and VBA work - you can create a macro (not embedded), using Create-Macro-Macro. Add a few lines and save it as Macro1.

    Click on the Database Tools tab on the ribbon.

    Then you can click on the Macro1 in the navigation pane, and on the Macro section of the ribbon click "Convert Macro to Visual Basic". It will generate a module "Converted Macro- Macro1". Double click this module to open VBA editor. Here you can examine, edit, and reuse the code.

    Nadia

    Tuesday, July 06, 2010 4:08 PM