Skip to Content
0
Former Member
Jul 17, 2008 at 02:16 PM

Cancel button in CFL Form

110 Views

Hi all,

In all the user forms I've developed, every time I click the "Cancel" button in a ChooseFromList form, my add-on stops responding. Can some one help me? I've posted some code bellow.

Could it have to do with not setting the BubbleEvent property?

Calling a sub to handle the event.

 Case SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST    
                If pVal.FormTypeEx = "frmNR" Then FormNRCFL(oCompany, oApplication, FormUID, pVal, BubbleEvent)

        Public Sub FormFolhaCFL(ByRef oCompany As SAPbobsCOM.Company, ByRef oApplication As SAPbouiCOM.Application, _
            ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean)

        Dim oCFLEvent As SAPbouiCOM.IChooseFromListEvent = pVal
        Dim sCFL_ID As String = oCFLEvent.ChooseFromListUID
        Dim oCFL As SAPbouiCOM.ChooseFromList = oForm.ChooseFromLists.Item(sCFL_ID)

        oForm = oApplication.Forms.GetForm(pVal.FormTypeEx, pVal.FormTypeCount)

        ...

        If pVal.ItemUID = "PrcCode" Or pVal.ItemUID = "PrcName" Then
            Dim oDataTable As SAPbouiCOM.DataTable = oCFLEvent.SelectedObjects

            If oCFLEvent.BeforeAction = False Then
                If (Not oDataTable Is Nothing) And oDataTable.Columns.Count <> 0 And oDataTable.Rows.Count <> 0 Then
                    Try
                        With oForm.DataSources.DBDataSources.Item("@ADAT_FOLHA")
                            .SetValue("U_PrcCode", .Offset, oDataTable.GetValue("U_PrcCode", 0))
                            .SetValue("U_PrcName", .Offset, oDataTable.GetValue("U_PrcName", 0))
                            .SetValue("U_CardCode", .Offset, oDataTable.GetValue("U_CardCode", 0))
                            .SetValue("U_CardName", .Offset, oDataTable.GetValue("U_CardName", 0))
                        End With
                        If oForm.Mode <> BoFormMode.fm_ADD_MODE Then oForm.Mode = BoFormMode.fm_UPDATE_MODE
                    Catch ex As Exception
                        oApplication.MessageBox("CFLEvent(Form: " & pVal.FormTypeEx & ", " & "Item: " & pVal.ItemUID & ")" _
                        & vbCrLf & "Erro: " & oCompany.GetLastErrorCode.ToString & ", " & ex.Message.ToString)
                    End Try
                End If
            End If
        End If

Thanks in advanced.

Best regards,

Vítor Vieira