Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

GP and VBA - How to Loop Through Grid

(0) ShareShare
ReportReport
Posted on by

In the grid on the Sales Transaction Entry window there is a box you can check for drop ship.  What I want to do is when a user clicks the 'Actions' button and chooses transfer, I want to check to see if drop ship is checked for all lines.  If any line item does not have drop ship checked then I want a message box to come up saying that.  I can't figure out how to do the VBA to have it loop through the grid to check each line to see if the drop ship box is checked.  Anyone have any ideas of how to do this?

Thanks
Jennifer

*This post is locked for comments

  • Andy Sather Profile Picture
    Andy Sather on at
    Re: GP and VBA - How to Loop Through Grid

    Thanks for the update on this Jennifer.  I will go ahead and close this post.

  • Re: GP and VBA - How to Loop Through Grid

    Hi Leslie

    Thanks for the reply.  Since the SOP10200 table has a column for dopship, I ended up doing a SQL statement to loop through the rows that were for that particluar PO and if it found the column Dropship = 0 for any of the line items it put up a message.

    Thanks

    Jennifer

  • Verified answer
    L Vail Profile Picture
    L Vail 65,271 on at
    Re: GP and VBA - How to Loop Through Grid

    Hi Jennifer,

    What I've done is to count the number of lines in the order and compare it to the sum of the DropShip field. You could compare the two numbers and put up the appropriate dialog. Something like:

    SELECT  

     COUNT(ITEMNMBR) AS LineItemCount

    , SUM(DROPSHIP) AS NumberOfDropships

    , COUNT(ITEMNMBR) - SUM(DROPSHIP) AS Difference

    FROM         SOP10200

    GROUP BY SOPNUMBE

    HAVING      (SOPNUMBE = 'ORDXXXX')

    Based on the above, display a dialog or whatever you want.

    Kind regards,

    Leslie

  • Re: GP and VBA - How to Loop Through Grid

    Hi Rubal

    Thanks for the reply.  Actually I already have VBA code that checks the drop ship box when they enter a line item.  I can't force it to be checked all the time since we do hold some inventory.  What I am looking for is when someone tries to transfer an order to an invoice to have it check and if some line items are not checked to display a message box to make sure the user knows.  I think Siva's answer might work or I can also see if I can come up with a SQL statement to check the SOP table for that particular order to see if the drop ship column for each line is equal to 0.

    Thanks

    Jennifer

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: GP and VBA - How to Loop Through Grid

    Hi Jennifer,

    Another workaround is you can write code when a line is added in the grid. Using this method you can notify user after he/she finished adding line in the grid.  SalesTransactionEntryDetail window represents the gird in the sales transaction entry window. You can write code for events like Grid_AfterLineChange and display message if dropdship checkbox is not checked on.

    Rubal,

    http://dynamicsgphelp.com/

  • Richard Wheeler Profile Picture
    Richard Wheeler 75,788 Moderator on at
    Re: GP and VBA - How to Loop Through Grid

    I know with the VS Toolkit you can loop through a datagrid but I do not know if the same objects are available using VBA.  If you switch to using the VS Toolkit the answer is a definite Yes.

  • veeyeskay Profile Picture
    veeyeskay on at
    Re: GP and VBA - How to Loop Through Grid

    Hello Jennifer

    You cannot loop through the records on the scrolling window. However, you can loop through the Line Item table for the specific sales document to see if the Dropship option has been selected for any line.

    Hope this helps. Let us know if you need further assistance.

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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans