(mis)information? (1 Viewer)

NauticalGent

Ignore List Poster Boy
Local time
Today, 11:01
Joined
Apr 27, 2015
Messages
6,286
Found this on a FB page today:
Microsoft Access Embedded Macro Vs Event Procedure
The best practice:
For the development of the user interface in Microsoft Access, we should use the built-in Macros/embedded Macros as many as possible. They run faster and also we can create Action Macros very fast instead of hand-coding.
.
Limitations:
There are a few limitations though. When we click the built-in Macro for navigation to the next record, it goes to the New if it is the last record. For this command, I always use "Event Procedure" like below. It will not go to New and if it is the last record and also, it will popup message for the user.
.
Private Sub CmdNext_Click()
If Me.CurrentRecord < Me.Recordset.RecordCount Then
DoCmd.GoToRecord Record:=acNext
ElseIf Me.CurrentRecord = Me.Recordset.RecordCount Then
MsgBox "This is the last record.", vbInformation + vbOKOnly, "Last"
End If
End Sub
.
If you are using this condition in an embedded Macro, then please let me know. It will help me.

I started to engage on the "Best Practice" bit, but then thought better of it.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 10:01
Joined
Feb 28, 2001
Messages
27,003
This is why I am not a Facebook member or subscriber or whatever it is that you do with it. I would have jumped down that person's throat in a heartbeat as a matter of giving advice without telling the whole story. However, there IS a grain of truth to be had.

VBA code is emulated, not true-compiled, so is "slow code." Macros can contain pre-compiled individual action routines. Their error handling sucks but they CAN be faster to execute. Or, more precisely, for simple macros it is not at all guaranteed, but they CAN be faster. The sucky error handling and faster execution probably go hand-in-hand, one a consequence of the other.

The more complex the macro sequence gets, the more likely it is that you really need to use VBA. But inherently, there is nothing totally and absolutely wrong with preferring macros for simple sequences. Particularly for people trying to use Access as a Rapid Application Development tool (which it IS), ease and relative efficiency of macros cannot be denied.

One of my strategies when developing my bigger projects was to use macros for lots of things until I could revisit each one to "spiffy it up into VBA" with all of the gadgets and bells and whistles. Because until I did revisit the ocde, I still had functional, if rather dull, event management.
 

oleronesoftwares

Passionate Learner
Local time
Today, 08:01
Joined
Sep 22, 2014
Messages
1,159
The best place(s) to get information are.

1. Official documentation
2. Forums like access programmers.co.uk :)
3. Any other reputable IT publication.
 

Users who are viewing this thread

Top Bottom