Results 1 to 8 of 8
  1. #1
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Convert to VB (A2K)

    When viewing a Form or Report in Design view (Access 2000), there is the ability to convert all Macros related to the Form/Report to Visual Basic.

    Tools | Macro | Convert To Visual Basic

    I stumbled across this in trying to gain some understanding as to how my Forms work and, hopefully, to get a little further down the road toward learning something about VBA. My question is, aside from the educational experience, what does this actually accomplish? Will the application run more efficiently as a result of this conversion, or are the existing Macros just as efficient?

    Blundering ahead, I actually did this conversion on one of my forms and all but crashed my app. (see attachment). I assume this occurred as a result of the Macro having already been converted to a Module at some point in the past. When I deleted the conversions, retaining the Macros, everything returned to normal. Some of the functionality of the form is based on Macro
    Attached Files Attached Files
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Convert to VB (A2K)

    If you have macros that serve your purpose, there is no compelling need to convert them to VBA code. One of the main advantages of VBA code over macros is that it is much more flexible and powerful, and much easier to maintain, so when the moment comes that you have to modify the macros, you might consider converting them to code.

    When you convert all of the macros associated with a form to code, the references to the macros in the Event tab of the Properties window are replaced by [Event Procedure], so after testing that the code works as intended (important!), you can delete the macros.

    The other way round is less easy. If you remove code, the references in the Event tab of the Properties window won't revert to the original macros.

    By the way, if you convert an individual macro to code, Access creates a standard module whose name begins with Converted Macro. This module is visible in the Modules tab of the database window, and it can be deleted normally.

    If you open a form in design view and select Tools | Macro | Convert Form's Macros to Visual Basic, the code is placed in the form module (at least in Access 2002, I don't have Access 2000); this module is not visible in the Modules tab. If you want to delete it, you must set the Has Module property of the form to No (in the Other tab of the Properties window.) You will lose ALL code behind the form this way.

  3. #3
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Convert to VB (A2K)

    Digesting. . .

    1. <LI>My assumption is that I can delete all current Modules (with the prefix "Converted Macro-")
      <LI>I can then go to each Form and use Tools | Macro | Convert to VB
      <LI>Delete each Macro associated with the Form
    After having done this, I can look at the [Event Procedure] to view (and learn from) the converted code. Should I decide to do this, I understand that I am not doing anything to immediately benefit the application, but only to "view" the code. Have I got that right?
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Convert to VB (A2K)

    Correct, but as usual, keep a backup copy of the current version, just in case...

  5. #5
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Convert to VB (A2K)

    Righty-O! (Backup, backup, backup. . .)
    Thanks for the guidance!
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  6. #6
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Convert to VB (A2K)

    A WORD OF CAUTION (for anyone following this thread).

    This process does not appear to work for Macro's used in the Switchboard.
    If there is a way to do that, I have not discovered it. Deleting those Macro's resulted in loss of Switchboard functionality. Thank God I was working in a copy!
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Convert to VB (A2K)

    You'll have to use the Switchboard Manager to edit the items to run code instead of running a macro.

  8. #8
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Convert to VB (A2K)

    Funny you should mention that. . .I was just looking at "Run Code", but didn't know what "Function Name" referred to.
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

Posting Permissions

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