Trapping SaveRecord and Display Existing Record in VBA

I can't swear this technique will work in all forms, but it works in Sales Transaction Entry. (3/5/2018: and PM Transaction Entry)

We often need to make change to data in a form, and we need to do it before the form saves or after it populates with data.

This technique will show you how.

Add the SaveRecord and DisplayExistingRecord fields to the form via Modifier

Open Sales Transaction Entry, open Modifier

Click on Layout > Show Invisible Fields. You'll see a bunch of fields surround the form. Drag SaveRecord and DisplayExistingRecord onto the form

Make them visible. In the screen shot below, one is visible and one is not.

Back in Dynamics, set security to the modified form.

EDIT 8/27/2016: In the form, click on Tools > Customize > Add fields to Visual Basic to make these new fields visible in the code behind

In VBA, add code to the DisplayExistingRecord_AfterUserChanged or the SaveRecord_BeforeUserChanged events.

The code below opens the Sales Date Entry form and populates a field. We could close the form also, if desired

 

EDIT 8/27/2016 After this is all over, carefully return to modifier and DRAG THESE FIELDS OFF THE FORM AGAIN. Note that this does not say 'delete the fields' (they may not ever be deleteable, not sure). Just move them off, out of the visible form. They'll still be available for you to code against.

 

 

 


RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences