Defaulting a field in Dynamics GP using VBA

If you have any interest in VBA and Dynamics GP, this is worth reading. It's a technique that I have not seen any documentation on.

The task is to default the Territory ID field in the Customer Maintenance form in Dynamics GP.

Normally, we'd trap the CHANGED event on the CUSTNMBR field and populate the Territory ID field, but the CHANGED event occurs before the form is populated so the default value gets wiped out when the form populates.

 

The technique is this:

This mod does not use a modified form, only VBA. However, we're going to modify the form and then delete the modification.

So, open the form in Modifier.

Drag the Display Existing Record field from below onto the form, set it's Visible property to TRUE

Go into Modified Forms and Reports and set security to the modified form.

Open the form, add the new field to VBA. If you have existing VBA, you'll have to set it to emModifiedOnly

Close the form.

Go to Tools > Customize > Modifier

Delete the modified form

Go into security and set security back to the original form

Go into the VBA editor and add a Changed event for Display Existing Record

When this event fires, the form is completely populated... now we can set our default.

 


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