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
Hello Jolash,
I have published an article about this subject, please find below step by step method:
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.
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.
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.
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?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156