Announcements
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
Yep, the Dispfields statement in LineGotFocus worked. Thanks again for all your help.
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
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 - you are awesome. That was exactly what I needed, to see an example. Thanks very very much!
John
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
André Arnaud de Cal...
294,060
Super User 2025 Season 1
Martin Dráb
232,858
Most Valuable Professional
nmaenpaa
101,158
Moderator