Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

SOP Sales Item Detail Entry in VBA

Posted on by Microsoft Employee

We have Sales Transaction Entry in VBA by reading the information from a third party table and populate the entry fields in the Sales Transaction Entry window (headers & details) without user intervention.  It was working perfectly fine in GP8 but after we upgrade to GP10, I am now getting errors.  The main problem  I’m facing now is when populating the entry field for Invoice Quantity and Quantity Returned in the SalesItemDetailEntry window.  If the Invoice quantity is higher than the available quantity, the SalesQuantityShortageOption window will open and we always select the default option “Override Shortage” by just clicking “OK” (SalesQuantityShortageOption.ok = 1) and the window will automatically close and go back to SalesItemDetailEntry window.  It was fine in GP8 but not in GP10. There are errors like "SalesQuantityShortageOption window still open" and "Quantity not properly distributed".  Please… is there any body who can help me, I’m stuck on this. Below is part of the code.

 

         strQty = Str(rsSop!Quantity)

         strUnitPri = Str(rsSop!UnitPrice)

         If SalesItemDetailEntry.IsLoaded = False Then

            SalesTransactionEntry.ExpansionButton5 = 1

         End If

         SalesItemDetailEntry.ItemNumber = rsSop!ItemNumber

         SalesItemDetailEntry.QTY.Focus

         SalesItemDetailEntry.QTY = strQty

         SendKeys "{TAB}", True

     

         If SalesQuantityShortageOption.IsLoaded = True Then

            SalesQuantityShortageOption.OK = 1

            SalesQuantityShortageOption.Close

         End If

 

         If SalesReturnedQuantitiesEntr.IsLoaded = True Then

            SalesReturnedQuantitiesEntr.OnHand = strQty

            SendKeys "{TAB}", True

            SalesReturnedQuantitiesEntr.OK = 1

         End If

         SalesItemDetailEntry.UnitPrice.Focus

         SalesItemDetailEntry.UnitPrice = strUnitPri

         SendKeys "{TAB}", True

         SalesItemDetailEntry.Save = 1

 

Thanks.

Salvo AB

*This post is locked for comments

  • Suggested answer
    Meng Yang Profile Picture
    Meng Yang 5 on at
    Re: Re: Re: Re: Re: SOP Sales Item Detail Entry in VBA

    You need to put in a condition to check the SalesTransactionEntryDetail.QtyAvailable after the QTY_AfterUserChanged event fires.  If the SalesTransactionEntryDetail.QtyAvailable <= 0 then you do nothing and allow Microsoft GP to handle the event.  The SalesQuantityShortageOption window will then open and you can use your code to handle this event.

    or

    Sub QTY_AfterUserChanged()

    If SalesTransactionEntryDetail.QtyAvailable > 0 then

    (Here's where your code goes when the item is not out of stock or discontinued)

    Else

    (Do not put any code here, Microsoft GP will handle the event where SalesTransactionEntryDetail.QtyAvailable <=  0, and the SalesQuantityShortageOption window will then open)

    End If

    End Sub

    Once Microsoft GP handles the event where SalesTransactionEntryDetail.QtyAvailable <=  0.  You can use your code to handle the SalesQuantityShortageOption window event.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: Re: Re: Re: Re: SOP Sales Item Detail Entry in VBA

    My original code doesn't have the close method. I just added it hoping it will solve the problem since the SalesQuantityShortageOption window is still open when it gives the error "Quantities must be distributed before you can save this item".  It seems the command line "SalesQuantityShortageOption.Ok=1" doesn't affect.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: Re: Re: Re: SOP Sales Item Detail Entry in VBA

    These two lines:

     

    SalesQuantityShortageOption.OK = 1

    SalesQuantityShortageOption.Close

     

    Aren't they redundant? Because hitting OK effectively closes the window?


  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: Re: Re: SOP Sales Item Detail Entry in VBA

    Hi Ruel,

    Thanks also for your reply,

    In refering to a particular field, I'm using the Focus method.  Maybe I'm missing something in my code, but I can't find what it is.

    Thanks,

    Salvo 

     

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: Re: SOP Sales Item Detail Entry in VBA

    Hi Dencio,

    Thanks for your reply.

    I created an invoice manually both sales & return invoice and it went smooth.  After I enter sales qty, SalesQuantityShortageOption window opens and manually click Ok button accepting the default "Override Shortage", the window automatically closed and back to SalesItemDetailEntry window and saved.  But when I use my VBA code, it thus open the SalesQuantityShortageOption window but up to there only.  The command "SalesQuantityShortageOption.Ok=1" seems not working because the window is still open and the default "Override Shortage" was not selected thereby generating errors for the succeeding command lines. Or maybe I'm missing something.

    Thanks,

    Salvo

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: Re: SOP Sales Item Detail Entry in VBA

    From a cursory glance at your code, I see that you are using the SendKeys method to move from field to field. I have a feeling, though I am not perfectly sure at this point, that the tab order may have changed since it is likely the new version will have more fields. So you might want to look into that.

  • Dencio Profile Picture
    Dencio 2,172 on at
    Re: SOP Sales Item Detail Entry in VBA

    Hi Salvo,

    Before we go deeper into VBA concern which from what I see is still valid, can you run a simple test of creating an invoice and manually performing as you described without the VBA code and verify whether GP will not encounter the same validation process.

    Let us know the results and we can assist further.  Especially intriguing is the error message 'Quantity not properly distributed' since you mentioned you are overriding the shortage.

    Cheers,

    Dencio

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