Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

Check error state of Dynamics GP window using VBA

Posted on by 115

I am trying to add a couple of field and check boxes into the Debtor Item Maintenance window in Dynamics GP. I have managed to get these added and they are working fine including using DUOS to read/write/delete the information stored in these fields for each debtor item. 

The issue I am currently having is that when I type a debtor ID or item number that does not exist into their respective fields, I want the VBA code to recognise that an incorrect debtor ID or item number has been entered and therefore not continue with the code. 

For instance, in the code below, the sub runs after the debtor ID has been changed and enables the new check boxes. However I don't want it to run if the debtor ID has been flagged as one that doesn't currently exist.

Private Sub DebtorID_AfterUserChanged()

    ' Check that the DebtorID isn't incorrect
    ' This would result in GP raising an error box asking
    ' if the user wants to cancel or add the new Debtor ID
    ' If this error has been raised, don't run the code below

    ' Enable the new check boxes
    NewCheckBox1.Enabled = True
    NewCheckBox2.Enabled = True


End Sub


*This post is locked for comments

  • RyanSinfield Profile Picture
    RyanSinfield 115 on at
    RE: Check error state of Dynamics GP window using VBA

    Better yet, is there a tutorial or something I can look at for a detailed explanation?

  • RyanSinfield Profile Picture
    RyanSinfield 115 on at
    RE: Check error state of Dynamics GP window using VBA

    Mariano, thanks for the reply. How do I move this existing field into the Debtor Item Maintenance window?

  • Verified answer
    Mariano Gomez Profile Picture
    Mariano Gomez 26,225 on at
    RE: Check error state of Dynamics GP window using VBA

    Typically, every Microsoft Dynamics GP maintenance window has a field called Display Existing Record. This field is a checkbox data type field and is set to true if the current record was displayed successfully.  What you want to do is temporarily move this field to the Debtor Item Maintenance window and change the Visible property True. You will then want to add this field to VBA like you've done with others.

    You will change your event to evaluate on this field rather than what you are trying to do currently. NOTE: both the item and vendor fields will run the Display Existing Record change script and will set the proper value to this check mark.

    Once you have added the field to VBA, don't forget to return to Modifier and move the field back off the screen and set the Visible property to False.

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans