web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics SL (Archived)

Adding field from another table to grid in SL 7.0

(0) ShareShare
ReportReport
Posted on by 95

I am trying to add a field from the purorddet table to the Sales Order Entry screen (40.100.00).  The field is used to store a tracking number for Sales Orders that generate a Purchase Order.  I have added the Purorddet table to the screen using a VBASetAddr call, and have declared a cursor on the PurOrdDet table using SQLCursorEx.  I have written a stored procedure that returns the Purorddet record when supplied with a Sales Order number and Lineref value. Finally, I have added the field from purorddet to the Sales Order Entry screen, in the grid.

When I put code in the check event for the Order Number, the code fires and the Tracking number populates on the first line item for the order.  However, all subsequent lines show the same tracking number as the first line.

I know I likely have to loop through the lines in the grid and execute the stored procedure for each line, but I am not sure how to do that in VBA.  Any help would be very much appreciated.

 

John

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Barry Flynn Profile Picture
    3,090 on at

    John

    One thing you may have missed is putting a VBA_Mextend call in Form Display.

    That "adds your buffer" to the grid.

    Without that call, there is just one instance of your buffer, holding a single value.

    When you do that call, there are multiple instances of your buffer - one per grid line.

    You are right in saying that you need to execute the proc for each line.

    The code may (or may not) look a little bit like this

       liRowNum = MGetRowNum(garrFAHandle)

       liGridFetch = MFirst(garrFAHandle, liMaintFlg)

       Do While liGridFetch = 0

               --- run your proc & populate your buffer

               Call MUpdate(garrFAHandle)

           liGridFetch = MNext(garrFAHandle, liMaintFlg)

       Loop

       ' point the grid back where it was before we started

       Call msetrownum(garrFAHandle, liRowNum)

       Call MDisplay(garrFAHandle)

    Hope that helps a bit

    Barry

  • John Kowalke Profile Picture
    95 on at

    Barry - you are awesome.  That was exactly what I needed, to see an example.  Thanks very very much!

    John

  • John Kowalke Profile Picture
    95 on at

    One additional question, if anyone has an answer.  My grid now shows the field properly for each line in grid view, but when I select a line and switch to form view, the field only shows the value for the first line, no matter which line is selected.  Do I need to put code in the LineGotFocus event for the grid to update the field when a line is selected?

    Thanks,

    John

  • Barry Flynn Profile Picture
    3,090 on at

    John

    As a wild (and probably silly) guess, you might consider putting a DispField of your field in LineGotFocus.

    But that is probably a silly suggestion, because, to my knowledge, you shouldn't need to do anything.

    Form View should "just work".

    Barry

  • John Kowalke Profile Picture
    95 on at

    Yep, the Dispfields statement in LineGotFocus worked.  Thanks again for all your help.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics SL (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans