473,474 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Embedded Macros Vs VBA

PhilOfWalton
1,430 Recognized Expert Top Contributor
Assuming someone is reasonably proficient at writing both Macros & VBA so that ease of learning is NOT relevant, and also appreciating that a number of things can only be done using VBA (API calls, Class Modules etc.) could the experts offer views on the advantage of each method for the more basic functions (Opening forms, searches etc)

Phil
Aug 9 '17 #1
11 2601
ADezii
8,834 Recognized Expert Expert
Here is an interesting Article written by a Bytes Moderator some years ago, hope it is helpful. Some of this Article is no longer applicable since the newer Versions of Access were released.
Macros or VBA?
Aug 10 '17 #2
PhilOfWalton
1,430 Recognized Expert Top Contributor
I think that when that article was written, the guy was referring to macros, rather than Embedded Macros.

I personally never use macros (Except AutoExec occasionally), but am trying to establish if they have any advantages, particularly when using non-Access back ends (SQL Server, MySQL, Silverlight etc)

Phil
Aug 10 '17 #3
NeoPa
32,556 Recognized Expert Moderator MVP
Hi guys.

@ADezii.
I'm intrigued to hear some of the points in the article are no longer applicable. Do you have some examples for me to consider? I couldn't see anything affected by new versions when I skimmed through it again.

@Phil.
The author is Mary (McCarthy). A lovely Irish lady who no longer has much time to devote to Bytes.com, but whom I work with from time to time. Neither of us has been a member as long as ADezii here.

I'm curious to understand what you're referring to with the term 'Embedded Macros'. I couldn't follow that point I'm afraid.

As a general rule, even assuming full expertise in both macros and VBA, I would recommend the latter, as all but the simplest of projects will require some VBA due to the limited nature of using macros. Assuming then, the use of VBA, why would anyone complicate a project by having some of both. I've inherited projects of that type in the past and it was never fun to deal with. Once all the macros had been replaced by VBA it was much easier to work with.

I hope this is some help.
Aug 12 '17 #4
NeoPa
32,556 Recognized Expert Moderator MVP
Bizarrely enough, I've just had Embedded Macros explained to me by Access MVP and guru Crystal Long. This is a new feature with ACCDBs which I've never come across because I don't believe using macros ever makes sense in an Access database. Embedded or otherwise (and Crystal informs me that the undocumented feature AccessApp.SaveAsText(ObjectType:=acMacro, ObjectName:=..., FileName:=...) saves Embedded Macros in an entirely new XML format.) I don't believe having macros in a project with VBA makes any sense at all. Everything a macro can do can equally, and generally better, be done in VBA. You can even call a VBA function procedure directly as an Event destination (by setting the property to =YourFunctionName() - optionally with parameters) rather than always having to direct it to the Event Procedure (by setting the property to [Event Procedure]).

Hopefully that answers your question more fully Phil.
Aug 12 '17 #5
ADezii
8,834 Recognized Expert Expert
@NeoPa:
A couple of points that I was referring to are:
Macros are not saved with the form they are designed to act on, but as separate objects, whereas your VBA code is saved with the form it belongs to.
No longer true with 'Embedded Macros'
Using VBA allows you to use Public Variables
You can declare variables publicly either to a form or to a database by declaring them in a module. This means you can pass a value to those variables and have it retain that value for use in various of your objects (reports; forms; etc).
The use of TempVars has changed this since they retain their Value until either Access is closed, or they are explicitly removed from memory.
Aug 12 '17 #6
PhilOfWalton
1,430 Recognized Expert Top Contributor
There appears to be confusion between macros & Embedded Macros. AFIK, Embedded macros are saved with the form.

Please, Don't get me wrong, I have always used VBA, but Embedded Macros are, I believe, a comparatively recent development (Access 2007 and later). I hate to say this, but 10 years ago for me is recent...

So there must have been a reason for their addition, and I am trying to find out why.

Phil
Aug 12 '17 #7
NeoPa
32,556 Recognized Expert Moderator MVP
@ADezii.
Indeed. Your first point I recently discovered.

TempVars are an addition and are also available to macros. That doesn't imply the statement in the article is no longer correct. VBA does allow use of Public Variables. That's a less important difference now, but still fundamentally true. However, I think I understand you better now anyway.

@Phil.
You seem to be implying Embedded Macros are separate from Macros generally. I see them as a subset thereof, albeit saved in a different place.

My earlier comment is based on the idea that where they're saved is fundamentally irrelevant and usage of any type of macro in a project is likely to make your life harder than simply using VBA.

I'm afraid I have no insight into why the Embedded Macro was added as a thing, when linking to named macros worked in fundamentally the same way. The only pertinent difference I can see is that they're not so easily (if even possibly) reusable. Nothing I know about them would lead me to recommend them to anyone who could do even the most basic work in VBA.

If I do hear anything that might throw any light on that decision I'll try to remember to feed it back to you.

PS. I asked it of the other Access MVPs (& alumni) so maybe you'll get an answer later.
Aug 12 '17 #8
ADezii
8,834 Recognized Expert Expert
Just a couple of additional points regarding Embedded Macros.
  1. Embedded Macros are stored in an Event Property and is part of the Object to which it belongs. That being said, each EM is totally independent from each other.
  2. EMs are not visible in the Navigation Pane and are only accessible from the Object's Property Sheet.
  3. Embedded Macros are Trusted and even run if your Security Settings are set to prevent the running of Code.
  4. Using thee Macros allows you to distribute your Application as a 'Trusted' Application because Embedded Macros are automatically prevented from performing unsafe operations.
P.S. - Personally, I never use Embedded Macros, and there are only two standard Macros that I will ever use: AutoExec, and AutoKeys.
Aug 12 '17 #9
NeoPa
32,556 Recognized Expert Moderator MVP
You've stolen my thunder a little there ADezii. Well done. Here are some extra considerations :
  1. TheSmileyCoder:
    Another bonus of embedded macros is that they copy/paste along with the control. So if you have a generic "Close form" button, then you can copy paste it along with the logic behind it.
    I'm not sure that's such a big issue really as that could be done with standard named macros too of course.
  2. TheSmileyCoder:
    I use a splash form that says "This project is not trusted, click the button blah blah". The form's onOpen event closes itself, and opens the login form. So if code IS trusted, the form is never shown.
    Quite clever really :-)

    That might be another to add to your list of exceptions ADezii.
Aug 12 '17 #10
Nancy845
1 New Member
Macros can also facilitate the users in creating graphs or charts. If the tasks of copying and pasting the data or making calculations based on the assigned formulas are done repetitively, macros is of obvious importance and great use to carry out such activities effectively.
Aug 14 '17 #11
NeoPa
32,556 Recognized Expert Moderator MVP
Hi Nancy.

I'm not sure I can agree with that, not if I understand you correctly. When we talk about macros in Access we're not talking about VBA, as we might be if say we were talking about Excel. In Access macros are a different animal. There are extremely few situations where use of macros can't (and indeed they should) be replaced by VBA code. Very few experienced developers use more than the absolute basics of macros (AutoKeys etc). Anders has given a good example of an embedded macro that can be very useful if you don't have control of the environment the project may run within.
Aug 15 '17 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: Chris Reedy | last post by:
For everyone - Apologies for the length of this message. If you don't want to look at the long example, you can skip to the end of the message. And for the Python gurus among you, if you can...
37
by: seberino | last post by:
I've been reading the beloved Paul Graham's "Hackers and Painters". He claims he developed a web app at light speed using Lisp and lots of macros. It got me curious if Lisp is inherently faster...
10
by: Jean-David Beyer | last post by:
I have some programs running on Red Hat Linux 7.3 working with IBM DB2 V6.1 (with all the FixPacks) on my old machine. I have just installed IBM DB2 V8.1 on this (new) machine running Red Hat...
12
by: Bill Hanna | last post by:
C is inadequate for embedded systems for the following reasons: 1) Direct addressing of memory mapped I/O is not supported simply and easily. You have to find work-arounds that are compiler...
37
by: hasadh | last post by:
Hello, probably this may be a simple qn to u all but I need an answer plz. In my software i used macros like OK,TRUE,FALSE,FAILURE . A friend who included this code as a library into his module...
6
by: Tom Torfs | last post by:
Hello All, I've been missing the lack of support for binary numeric literals in C. To get around it I wrote the following handy macros, which allows you to simply write something like: ...
27
by: Cephalobus_alienus | last post by:
Hello, I know that macros are evil, but I recently came across a problem that I couldn't figure out how to solve with templates. I wanted to create a set of singleton event objects, and wrote...
2
rsmccli
by: rsmccli | last post by:
Hello. Using Access 2002. I have set up a command button on a form that will print off a list of hyperlinked documents that resides in one of our tables. I have been using code borrowed from Graham R...
15
topher23
by: topher23 | last post by:
Greetings all! It's been a while since I've been around - I went out and got a degree (double-concentration in English Ed and Creative Writing of all things), then went right back into a job in RAD...
3
PhilOfWalton
by: PhilOfWalton | last post by:
I have been helping some people on this forum with their Access problems, and find some of them are using Embedded Macros as well as Event Procedures on their forms. I have always used Event...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.