web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Error 20217: "The VBA code could not be compiled for execution"

(0) ShareShare
ReportReport
Posted on by 63

I'm upgrading a Dynamics SL 7.0 version to Dynamics SL 2018.  One of my custom buttons doesn't work after the upgrade.  When I go into the code using the VB editor and save the code it give the message "System Message 20217  The VBA code could not be compiled for execution."

I found, in one post, that the signature of the Update1 methods had changed and that the for each of those methods, you needed to set all but the last parameter to ByRef.  The author claimed that solved their problem.  I changed signatures of the three Update1 methods as follows, but it didn't make a difference.

Private Sub Update1_OnFinish(ByVal Level As Integer, ByVal Updated As Integer, retval As Integer)

Private Sub Update1_OnInsert(ByVal Level As Integer, retval As Integer)

Private Sub Update1_OnUpdate(ByVal Level As Integer, ByVal InsertFlg As Integer, retval As Integer)

Does anybody know how to fix this?  I need a solution as soon as possible.

Thanks!

I have the same question (0)
  • CFROTON Profile Picture
    4,710 on at

    Hello

    Was the post you refer to found here: www.steadycode.com/.../

    If not, take a look ..I'll go ahead and have someone take a look at this.

    Thank you,

    Jana MacDonald

  • antiquemapman Profile Picture
    63 on at

    Yes, that's the article I was referring to.  After making his suggested changes, the problem remained.

  • Suggested answer
    CFROTON Profile Picture
    4,710 on at

    This is a bug. 36455, There is no fix but, There are 2 possible workarounds for this issue:

    Workaround 1:

    1.  In the Microsoft Dynamics SL main screen, select Administration->Select Customization Level.

    2.  In the Select Customization Level (91.260.00) screen, select the level of the customization being loaded - e.g. All Users.  Check the Exclude Event Code box.  Close the Select Customization Level screen.

    3.  Load the screen containing the errant VBA code.  Select Customize Mode from the dropdown menu.  Then select the Visual Basic Editor from the dropdown menu, or press F7.  The Visual Basic Editor will load.

    4.  For each Update method defined in the customization, change the method signatures to include a ByVal qualifier as follows:

    Private Sub Update1_OnCancel(ByVal Level As Integer, retval As Integer)

    Private Sub Update1_OnDelete(ByVal Level As Integer, retval As Integer)

    Private Sub Update1_OnFinish(ByVal Level As Integer, ByVal Updated As Integer, retval As Integer)

    Private Sub Update1_OnInsert(ByVal Level As Integer, retval As Integer)

    Private Sub Update1_OnUpdate(ByVal Level As Integer, ByVal InsertFlg As Integer, retval As Integer)

    5.  Select Debug from the Menu bar and select Compile Project...  There should be no errors returned.

    6.  Select File->Save Project... or select the Save button.  Select Customize->Customize Mode to close the VBA editor and exit customization mode.  Close the application.

    Note that steps 2 - 6 must be repeated for each customization level that contains code for one or more Update events.

    Workaround 2:

    1.  Select Administration->Export Customizations (91.500.00).

    2.  Select the box for the screen and customization level containing the errant VBA code.

    3.  Enter a path for the exported file in the Export File: box, and check the Export VBA as Source box at the bottom of the screen.  Press Begin Processing.

    4.  Open the exported customization file with a text editor, such as Note pad.  

    5.  For each Update method defined in the customization, change the method signatures to include a ByVal qualifier as follows:

    Private Sub Update1_OnCancel(ByVal Level As Integer, retval As Integer)

    Private Sub Update1_OnDelete(ByVal Level As Integer, retval As Integer)

    Private Sub Update1_OnFinish(ByVal Level As Integer, ByVal Updated As Integer, retval As Integer)

    Private Sub Update1_OnInsert(ByVal Level As Integer, retval As Integer)

    Private Sub Update1_OnUpdate(ByVal Level As Integer, ByVal InsertFlg As Integer, retval As Integer)

    6.  Save the customization file.

    7.  Selct Administration->Import Customizations (91.510.00).  Select the Browse button, and open the modified customization file.  Select Begin Processing.

    8.  The customization should import correctly.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans