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)

How to add Labour Class description to Transaction Detail Enquiry screen grid

(0) ShareShare
ReportReport
Posted on by 1,639

Hi There,

I want to add the Labour Class Description( next to the labour class) into the grid on the TRansaction Detail Enquiry (project) screen (PATRD). I have added code in VBA in the chk field event of the labour class field (pjtran.tr_id05) but as this is an enquiry screen I cannot get this code to trigger and populate the description as the labour class is already there and not being entered by the user. I am using SL 2011. Can anybody help me?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Apps Mexico Profile Picture
    1,090 on at

    You can try to do something like this, when the user press the OK-Load button. This code extends the grid to add another table.

    Private Sub Form1_Load()

       Call VBA_SetAddr("bxReasonCodeAdic", bxReasonCodeAdic, nxReasonCodeAdic, LenB(bxReasonCodeAdic))

       Call SqlCursorEx(CSR_xReasonCodeAdic, NOLEVEL, "CSR_xReasonCodeAdic", "bxReasonCodeAdic", "bxReasonCodeAdic")

       Call LoadComboBoxList

    End Sub

    Private Sub Form1_Display()

       GridHandle = GetGridHandle("Spread1")

       DelGridHandle = GetDelGridHandle("Spread1")

       serr1 = VBA_Mextend(GridHandle, bxReasonCodeAdic, LenB(bxReasonCodeAdic))

       iRowNum = MGetRowNum(GridHandle)

       serr1 = MFirst(GridHandle, MaintFlag)

       Do Until serr1 = NOTFOUND

           Call GetBufferValue("bReasonCode.ReasonCD", bxReasonCodeAdic.ReasonCD)

           sSqlStr = "Select * From xReasonCodeAdic Where ReasonCD = " & SParm(bxReasonCodeAdic.ReasonCD)

           serr1 = SqlFetch1(CSR_xReasonCodeAdic, sSqlStr, bxReasonCodeAdic, LenB(bxReasonCodeAdic))

           If serr1 = 0 Then

               Call MUpdate(GridHandle)

           End If

           Call MUpdate(GridHandle)

           serr1 = MNext(GridHandle, MaintFlag)

       Loop

       Call msetrownum(GridHandle, iRowNum)

       Call MDisplay(GridHandle)

    End Sub

  • Jo Wykerd Profile Picture
    1,639 on at

    Thanks for this code Juan.

    Is this the exact code I would use or just an example? The table where the labor code description is PJCODE so I am assuming that this is just an example.

    Also what is LoadComboBoxList?  Gives an error on that

  • Apps Mexico Profile Picture
    1,090 on at

    That code is an example and you can delete the LoadComboBoxList line, this is a method to populate a combobox control from values stored on a table.

  • Jo Wykerd Profile Picture
    1,639 on at

    Thanks Juan I have changed the code to suit my requirements.  The only think is that Spread1 doesnt exist in SL2011.  Do you know what to use to identify the grid?

  • Apps Mexico Profile Picture
    1,090 on at

    Usually the grid control is called Spread1, Spread2, acording to the level that represents, but on this case the grids name is "ssinq", the grid control is the only one that have the LineChk and LineGotFocus events.

    Change the Spread1 to ssinq.

  • Jo Wykerd Profile Picture
    1,639 on at

    sorry about all these questions but getting error when I put code you suggested behind the OK-Load button.  Says 'Mextend calls should be made in the Form1_display events in basic script language code".  I cant put it in there as data only gets loaded into grid when button pressed.  Any suggestions please?

  • Apps Mexico Profile Picture
    1,090 on at

    That is because the MExtend allows you extend the grid to can add the description control and always must to be on the form display event.

    This isn't the exact code but you can get an idea.

    Private Sub Form1_Load()

      Call VBA_SetAddr("bPJCode", bPJCode, nPJCode, LenB(bPJCode))

      Call SqlCursorEx(CSR_PJCode, NOLEVEL, "CSR_PJCode", "bPJCode", "bPJCode")

    End Sub

    Private Sub Form1_Display()

      GridHandle = GetGridHandle("Spread1")

      DelGridHandle = GetDelGridHandle("Spread1")

      serr1 = VBA_Mextend(GridHandle, bPJCode, LenB(bPJCode))

    End Sub

    Private Sub OKButton_Click()

      iRowNum = MGetRowNum(GridHandle)

      serr1 = MFirst(GridHandle, MaintFlag)

      Do Until serr1 = NOTFOUND

          Call GetBufferValue("bReasonCode.ReasonCD", bPJCode.ReasonCD)

          sSqlStr = "Select * From PJCode Where Code = " & SParm(bPJCode.ReasonCD)

          serr1 = SqlFetch1(CSR_PJCode, sSqlStr, bPJCode, LenB(bPJCode))

          If serr1 = 0 Then

              Call MUpdate(GridHandle)

          End If

          Call MUpdate(GridHandle)

          serr1 = MNext(GridHandle, MaintFlag)

      Loop

      Call msetrownum(GridHandle, iRowNum)

      Call MDisplay(GridHandle)

    End sub

  • Jo Wykerd Profile Picture
    1,639 on at

    Hi Juan,  I have pretty much got the code working except for 2 things :- the labour description only populates in the grid the second time you press the Ok-Load button (still blank after pressing first time) and all the labour descriptions in the grid are the same (last ones labour code used).  Here is my code :-

    Public CSR_xPJCODE As Integer

    Private Sub cmdLoad_Click()

       irownum = MGetRowNum(GridHandle)

       serr1 = MFirst(GridHandle, MaintFlag)

       Do Until serr1 = NOTFOUND

           Call GetBufferValue("bpjtran.tr_id05", bxPJCODE.code_value)

           ssqlstr = "Select * From PJCODE Where code_value = " & SParm(bxPJCODE.code_value)

           serr1 = SqlFetch1(CSR_xPJCODE, ssqlstr, bPJCODE, LenB(bPJCODE))

           If serr1 = 0 Then

               Call MUpdate(GridHandle)

           End If

           Call MUpdate(GridHandle)

           serr1 = MNext(GridHandle, MaintFlag)

       Loop

       Call msetrownum(GridHandle, irownum)

       Call MDisplay(GridHandle)

    End Sub

    Private Sub Form1_Display()

       GridHandle = GetGridHandle("ssinq")

       DelGridHandle = GetDelGridHandle("ssinq")

       serr1 = VBA_Mextend(GridHandle, bxPJCODE, LenB(bxPJCODE))

    End Sub

    Private Sub Form1_Load()

      Call VBA_SetAddr("bPJCODE", bPJCODE, nPJCODE, LenB(bPJCODE))

      Call SqlCursorEx(CSR_xPJCODE, NOLEVEL, "CSR_xPJCODE", "bxPJCODE", "bxPJCODE")

    End Sub

  • Jo Wykerd Profile Picture
    1,639 on at

    Hi Juan,  are you possibly able to help me with these 2 problems listed above?  Hopefully the last time I have to ask for your help. Thanks so much.

  • Apps Mexico Profile Picture
    1,090 on at

    Hi, I don't have the project module installed, i can't taste the code but try with this:

    How is the fieldname property of your description control?

    Use the serr1 to move in your grid and another serr like serr2 to query your db.

      Do Until serr1 = NOTFOUND

          Call GetBufferValue("bpjtran.tr_id05", bxPJCODE.code_value)

          ssqlstr = "Select * From PJCODE Where code_value = " & SParm(bxPJCODE.code_value)

          serr2 = SqlFetch1(CSR_xPJCODE, ssqlstr, bPJCODE, LenB(bPJCODE))

          If serr2 = 0 Then

              Call MUpdate(GridHandle)

          End If

          serr1 = MNext(GridHandle, MaintFlag)

      Loop

      Call msetrownum(GridHandle, irownum)

      Call MDisplay(GridHandle)

    End Sub

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