Skip to Content
0
Former Member
Apr 22, 2011 at 12:00 PM

Setting Business Partner PriceList through UI

44 Views

I'm trying to automatically change the value of the Business Partner PriceList when the user selects a different Group.

First i tried just setting the value, and the error message told me to use CallByName(). Now I'm getting "Error:438: Public member '81' on type 'FormClass' not found." Thanks for the help!


'Checking if processing'
        If bProcessingLostFocus Then Exit Sub
        Try
            If pVal.BeforeAction Then
                'BEFORE EVENT'
            Else

                'AFTER EVENT'
                Select Case pVal.ItemUID

                    'Set PriceList when Group changes
                    Case "16"

                        'Declaring the needed variables'
                        Dim oRec As SAPbobsCOM.Recordset
                        Dim sQuery As String = ""
                        oRec = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

                        'Creating & Executing the query'
                        sQuery = "select ListNum from ocrg, opln where ListName = GroupName and ocrg.GroupCode = " & oForm.Items.Item("16").Specific.Selected.Value
                        oRec.DoQuery(sQuery)

                        'Checking the returned record (if any)'
                        If oRec.RecordCount > 0 Then
                            MsgBox("Changing PriceList to " & oRec.Fields.Item(0).Value)

                            'HERE IS WHERE THE CODE ERRORS'
                            'oForm.Items.Item("81").Specific.Selected.Value = oRec.Fields.Item(0).Value
                            CallByName(oForm, "81", CallType.Set, oRec.Fields.Item(0).Value)
                        End If

                        'Freeing the memory'
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(oRec)
                        oRec = Nothing
                End Select

            End If
        Catch ex As Exception
            'MsgBox("error")
            lErrNum = Err.Number
            oErr.ShowMsg(lErrNum, ex)
        End Try