Skip to main content
Post a question

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id : xIBBi+8GKhRJ0FFSaSM8z1
Microsoft Dynamics GP (Archived)

Custom vba issue when moving from GP 2015 - GP 2015 R2

Like (0) ShareShare
ReportReport
Posted on 24 Sep 2015 18:43:43 by

Hey all,

I am having an issue with some custom VBA code that we use to display a variable in the  SOP Entry window,

In 2015 I could use the statement:

customfield.Value = variable

In 2015 R2 this occasionally throws an odd error "1007". I have read a KB article and some other online resources about how to solve this, and apparently this method can cause some business logic errors.

The resolution is to instead use something with this syntax:

customefield.focus ("variable"). 

Great, easy fix right? Well now I am not getting anything to display in the customfield. I've even tried changing the entirety of the code once to first set focus without the variable, and then a sub aftergotfocus for the field to set the variable. Nothing, nada. I've put some checks in place to ensure that the sub aftergotfocus was running and it seems to never even run through so I believe something is going wonky with the .focus method. Does anybody have any ideas, or have experienced this in the past?

Thanks

*This post is locked for comments

  • Community Member Profile Picture
    on 02 Dec 2015 at 22:02:36
    RE: Custom vba issue when moving from GP 2015 - GP 2015 R2

    Hey Josh,

    Unfortunately using both methods in conjunction is what causes the issues I am trying to avoid in the first place appear. Here is the KB article related to my problems.

    support.microsoft.com/.../856199

    Steve endow also has an article about this issue.

    dynamicsgpland.blogspot.com/.../dynamics-gp-run-time-error-1007-unsafe.html

    Unfortunately the "fix" seems to have lost its functionality in 2015 R2, though I am unsure as to why. Thank you for your suggestion.

  • Suggested answer
    Josh P Profile Picture
    2,895 on 24 Nov 2015 at 02:55:02
    RE: Custom vba issue when moving from GP 2015 - GP 2015 R2

    Hi Matt,

    I believe .focus just makes the field active. So, if you use both concepts together, you may get the result you desire.

    Set the field active first by CustomField.Focus

    Then set the value CustomField.Value = variable

    Let us know if this works for you.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,884 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,748 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans
Loading complete