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 :
Microsoft Dynamics GP (Archived)

VBA 1006 error when setting field

(0) ShareShare
ReportReport
Posted on by

Hi,

I have added a new field to the SOP Entry window which first requires a Customer ID to be entered and if no customer number has been entered I want to clear that field.  I am running this script on the BeforeUserChanged of my new field.  When I debug and step to the line that clears my field I'm getting an error 1006, which reads 'Unsafe Operation.  This operation cannot be performed in the target field's AfterUserChanged, BeforeLostFocus, or AfterLostFocus Events.  This operation could compromise the integrity of the application'.

Below is the code I'm running:

   If CustomerID = "" Then

       MsgBox "Please enter a Customer ID"

       SalesTransactionEntry.MyField.Value = ""

       Exit Sub

   End If

any help would be greatly appreciated.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Congruent Dynamics Profile Picture
    735 on at

    Hi Rick

    Situation:

    You attempted to set a field’s value using the field’s AfterUserChanged, BeforeUserChanged or AfterLostFocus events. These events follow the Microsoft Dynamics GP user changed event. Microsoft Dynamics GP uses the user changed event to verify the value in a field; setting the value of the field after the Microsoft Dynamics GP user changed event does not allow the accounting system to verify the field.

    Solution:

    Set the field’s value using the BeforeGotFocus, AfterGotFocus events. These events precede the Microsoft Dynamics GP user changed event, and allow the accounting system to verify the contents of the field.

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 > 🔒一 Microsoft Dynamics GP (Archived)

#1
mtabor Profile Picture

mtabor 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans