cancel
Showing results for 
Search instead for 
Did you mean: 

object reference not set to an instance of an object

Former Member
0 Kudos

Hi,

I am getting the message "object reference not set to an instance of an object " addon execution.

Below code i have written in ItemEvent, plz check it and let me know the solution.

Case SAPbouiCOM.BoEventTypes.et_LOST_FOCUS

                If pVal.ItemUID = "c_vno" And pVal.BeforeAction = True And pVal.FormMode <> SAPbouiCOM.BoFormMode.fm_FIND_MODE Then

                    Try

                        Dim ds1 As SAPbobsCOM.Recordset

                        ds1 = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

                        ds1.DoQuery("SELECT T0.[U_VACC] as VN, T0.[U_LPAN] as LP, T0.U_TrpExpns as TE, T0.U_TrAcct as TA FROM [dbo].[ABC] T0 where T0.[Name]='" & frm1.Items.Item("c_vno").Specific.Value & "'")

                        frm1.Items.Item("vacct").Specific.Value = ds1.Fields.Item("VN").Value

                        frm1.Items.Item("c_lpan").Specific.Value = ds1.Fields.Item("LP").Value

                        frm1.Items.Item("trpxpns").Specific.Value = ds1.Fields.Item("TE").Value

                        frm1.Items.Item("tacct").Specific.Value = ds1.Fields.Item("TA").Value

                    Catch ex As Exception

                        oApplication.StatusBar.SetText("Item Event(Lost Focuse - 1) Failed" & ex.Message, SAPbouiCOM.BoMessageTime.bmt_Medium, SAPbouiCOM.BoStatusBarMessageType.smt_Warning)

                    Finally

                    End Try

                End If

With Regards

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

  1. Can you tell where (in what line) does your code fail?
  2. Also, please check that all variables are initialized:
    • oCompany
    • frm1
    • oApplication
  3. After ds1.DoQuery, you have to check that the query has found any records before you can refer to its fields. You should add this:

if ds1.RecordCount >  Then

     ds1.MoveFirst()

     'put your code here

      frm1.Items.Item("vacct").Specific.Value = ds1.Fields.Item("VN").Value

     .

     .

     .

End If

Beni.

Former Member
0 Kudos

hi.

This is a normal error. It is asking some reference.

First check it in source code..

enable  Exception

Control +Alt  and press E  and enable  exception..

you are pasting  some values ok

i think  here

define form

oForm = SBO_Application.Forms.Item("yourformuid")

before this code.

frm1.Items.Item("vacct").Specific.Value = ds1.Fields.Item("VN").Value

                        frm1.Items.Item("c_lpan").Specific.Value = ds1.Fields.Item("LP").Value

                        frm1.Items.Item("trpxpns").Specific.Value = ds1.Fields.Item("TE").Value

                        frm1.Items.Item("tacct").Specific.Value = ds1.Fields.Item("TA").Value

and

one more thing

where is the  form uid  in item event

If pVal.ItemUID = "c_vno" and pval.forumuid="yourformuid" And pVal.BeforeAction = True And pVal.FormMode <> SAPbouiCOM.BoFormMode.fm_FIND_MODE Then

if my suggestions not works wait for experts reply..

bye