Results 1 to 13 of 13
  1. #1
    Join Date
    Aug 2005
    Posts
    196

    Unanswered: Convert Module to macro

    I know it's possible to create a VB module from a macro - can you do the same the other way round? i,.e take a block of code, put into a module and convert a macro? Cheers.

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi

    Depends on the code. All macros can become code (they are accessed using the DoCmd object) however not all (in fact very little) code can become a macro. I would also suggest that that is regressive - there is no advantage of macros over code

    HTH
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    ..but you can call afunction from a macro, so implicitly your fragment of VBA can becoe a macro. IMHV there are times to use Macros, but once you are up to speed with VB/VBA these becoem fewer and far between

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Quote Originally Posted by healdem
    ..but you can call afunction from a macro, so implicitly your fragment of VBA can becoe a macro. IMHV there are times to use Macros, but once you are up to speed with VB/VBA these becoem fewer and far between
    That's an interesting statement. Where do you think macros are more applicable than the vba they inherently represent?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    some export procedures
    kicking off batch processes
    opening forms & reports using docmd etc...

    don't get me wron I'm not a fan of macros, just soemthime they are a usefull weapon in the war on the users behalf.

  6. #6
    Join Date
    Aug 2005
    Posts
    196
    Cheers for that - managed to convinve the boss that there are better ways of doing what we need to do!

  7. #7
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Quote Originally Posted by healdem
    some export procedures
    kicking off batch processes
    opening forms & reports using docmd etc...

    don't get me wron I'm not a fan of macros, just soemthime they are a usefull weapon in the war on the users behalf.
    I suppose now that I think of it, you have to reference a macro when creating custom menus. Of course my macros call custom vba functions so it ends up being a futile exercise...
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  8. #8
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    hi Teddy

    custom menus do not require macros - public sub in a module works fine.

    izy
    currently using SS 2008R2

  9. #9
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    I think the only macro I have ever used was an autoexec macro in a formless db but that isn't necessary either obviously. I would be interested in knowing anything a macro can do that code can't.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  10. #10
    Join Date
    Aug 2005
    Posts
    196
    Quote Originally Posted by pootle flump
    I think the only macro I have ever used was an autoexec macro in a formless db but that isn't necessary either obviously. I would be interested in knowing anything a macro can do that code can't.
    In this particular instance, we were wanting to add the code to a macro as the macro is set to automatically run every morning to update stock and we wanted to add the code to this macro. Maybe there's a better way?

  11. #11
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    If what you are doing is an automated process which runs at a specific time then there alternatives. I've used the autoexec macro to run a batch process kicked off by the windows scheduler. The macro called a series ofqueries and functions. The process ran after the backups had run, after the main system had done its processing and was used to repopulate local data with "our" snapshot of the corporate db.

    BTW I wasn't aware that there was a way of running code, without calling it from the autoexec macro in a formless db, would like to know the ins and outs of that opne pootleflump if you've got a minute....

    To me a macro is usually the first step from a purely drag and drop UI to developing VBA, most of the macros supplied in Access, and the ones developed by users have straightforward fucntional equivalents in VBA code. Thge advantage of the code is that you can do a great deal more with the code and fine tune it to meet requirements. To mangle the line from Animal Farm "macros good, vba code better", but at all times the important thing is to meet the user requirements, if they don't need the bells and whistles then don't waste time on them, ie if a simple macro will do the job, and thats what the users / customer is used to then stick with macros, if they require more then use vba functions, or mix and match as required.

    just my 2 1/2d

  12. #12
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by healdem
    BTW I wasn't aware that there was a way of running code, without calling it from the autoexec macro in a formless db, would like to know the ins and outs of that opne pootleflump if you've got a minute....
    You hit the nail on the head - you can't with a formless db. But nowadays I tend to create a hidden form instead of the autoexec.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  13. #13
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by pootle flump
    You hit the nail on the head - you can't with a formless db. But nowadays I tend to create a hidden form instead of the autoexec.
    sneaky, we (I) am not worthy....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •