Another recent request was to provide a method to prevent backdated transactions from being entered into Microsoft Dynamics GP. This means that we needed to validate the document date of a transaction as it as entered and again when it is saved. This is a perfect opportunity to demonstrate how Visual Basic for Applications (VBA) can add custom business rules to the application.
Note: If you want to take it one step further, you can check the transaction dates before attempting to post a batch of transactions. This is possible with VBA but would require the use of ADO (ActiveX Data Objects) to access the SQL data to validate the transactions in a given batch. This post will not be covering this additional level of complexity.
Below is summary of the steps used to add the business rules to the Sales Order Processing Sales Transaction Entry window:
The code needs to handle 3 events. The first event is when the user changes the Document Date field. The second and third events handle when the document is saved, both when the Save Button is pressed and also when save is selected from the "Do you want to save or delete the document?" dialog.
Note: The text for the PromptString in the Select Case statement in the Window_BeforeModalDialog() event will need to be adjusted to match the text for the transaction entry window where the code is being used.
An example package of the v10.0 Sales Transaction Entry window is attached at the bottom of the article.
Hope you found this example useful.
Sweeeet! David Musgrave shows how to prevent entry of a backdated transaction using VBA . There are few
PLEASE READ BEFORE POSTING
Please only post comments relating to the topic of this page.
If you wish to ask a technical question, please use the links in the links section (scroll down, on right hand side) to ask on the Newsgroups or Forums. If you ask on the Newsgroups or Forums, others in the community can respond and the answers are available for everyone in the future.