Skip to main content

Notifications

Microsoft Dynamics GP (Archived)

Runtime error when changing a field value.

Posted on by 140

Hello Everyone,

I am trying to reset the value of itemcodes when my users capture the details during a transaction.

For example when my users enter the item code: 'AAAAAA', I want to reset it to 'AA-AA-AA' when the itemcode field loses focus.

The idea is to save them the trouble of having to enter or remember the hyphens when they are entering a lot of items.

I have been able to write the VBA code and added this to the field's,  AfterUserChanged  Event so as to to change this entry however during run time , However , I get the following error:

"Runtime Error - An Attempt was made to set a value which violates the applications business logic . The operation could compromise the integrity of the application."

I would appreciate it if any one could suggest workaround or another approach. ( with code sample where available) to solve this problem.

Let me restate the problem- I need to refomart the field entry after the user has entered a certain value , before the next item is entered in the SOP grid.

Regards

Jason

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Runtime error when changing a field value.

    Hello Jolash,

    I have published an article about this subject, please find below step by step method:

    mohdaoud.blogspot.com/.../mask-field-in-dynamics-gp.html

  • Jolash Profile Picture
    Jolash 140 on at
    RE: Runtime error when changing a field value.

    Hello Mohammad,

    Thank you for your response. It was quite enlightening.

    I would go with option 1 - which says using the field mask. I Will read up on this but would greatly appreciate  it if you can give me steps to creating this mask for the item number field.

    I will describe what I am trying to achieve in more details.

    I want this mask to appear in the item number field on the Sales Transaction Entry window , so the cashier will just fill in the number between the fields e,g , "  -  --  " appears on a new line and  so they fill in the numbers in between these hyphens and the final result will be "AA-AA-AA".

    This way , they dont have to type in the hyphens themselves at run time.

    Many thanks.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Runtime error when changing a field value.

    Hello Jolash,

    Thank you for using the community.

    Please note that indeed this message will be shown in your case by system design, after leaving the item number field the system actually saves the record in temp tables and does not allow the item number to be changed, unlocking the field or setting values in the field will violates the application business logic and might cause many issues in the future.

    An solution for your case will be one of the following:

    1. You can use field mask over your field as same as the mask of the phone number used in vendor and customer maintenance forms, this will make it easier for your to do the customizations.

    2. If you would like to keep using VBA, you will need to select the event of BeforeUserChanged, it can look like the below:

    Private Sub ItemNumber_BeforeUserChanged(KeepFocus As Boolean, CancelLogic As Boolean)

    ItemNumber.Value = Left(ItemNumber.Value, 3) & "-" & Right(ItemNumber.Value, Len(ItemNumber.Value) - 3)

    End Sub

    3. If your customer has many items to be imported periodically I would recommend looking into Excel Paste, http://di.jo, it can help importing items into GP.

  • Jolash Profile Picture
    Jolash 140 on at
    RE: Runtime error when changing a field value.

    Yes I did  Richard , The data is appropriate for the field ( length and all). I only get this error at run time - and not at design time.

  • Richard Whaley Profile Picture
    Richard Whaley 25,195 on at
    RE: Runtime error when changing a field value.

    Have you made sure that the data you stuff back into the field is the proper length padded to the full field length with spaces at the end?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans