26 November, 2007

VBA Tip of the ?????

I'm not real committed to this blog as you can tell. But, I do have something to offer. Here's the first of some simple tips I might share ;)

Displaying a message box to a user and controlling their actions might be the easiest way to change the functionality of GP. You display the message box so they aren't confused when you alter the standard functionality of GP. This came up recently in a GP newsgroup post. Below is an example of forcing the user to enter a tracking number before clicking the Ready To Close buttin on RMA Entry Update. The CancelLogic = True prevents the Ready To Close logic from running if the TrackingNumber field is empty. You can put this on other BeforeUserChanged events in GP to alter the logic elsewhere.

Option Explicit
Dim Msg, Style, Title, Help, Ctxt, Response, MyString, Default

Private Sub SVCReadyToClose_BeforeUserChanged(KeepFocus As Boolean, CancelLogic As Boolean)
If TrackingNumber.Empty = True Then
Msg = "The Tracking Number is required before a RMA Line can be marked to close."
Style = vbOKOnly + vbCritical ' Define buttons.
Title = "Great Plains" ' Define title.
Help = "DEMO.HLP\" ' Define Help file.
Ctxt = 1000 ' Define topic
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
CancelLogic = True
KeepFocus = True
End If
End Sub

No comments: