cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting a record form UserTable

Former Member
0 Kudos

Hello,

I need to delete a record form my usertable called @TMPS

to add a record I use:


        Dim oUsrTbl As SAPbobsCOM.UserTable

        oUsrTbl = oCompany.UserTables.Item("MTPS")

        oUsrTbl.Code = CInt(sProduct)
        oUsrTbl.Name = CChar(sProduct)
        oUsrTbl.UserFields.Fields.Item("U_Depot").Value = "depot"
        oUsrTbl.UserFields.Fields.Item("U_Date").Value = CDate(dDate)
        oUsrTbl.Add()

oUserTbl.Remove exsists and I want to use it..but how.

Is there a way to select one record and then do

oUserTbl.Remove() ?

Thank you,

Michiel Kramer

Accepted Solutions (1)

Accepted Solutions (1)

AdKerremans
Active Contributor
0 Kudos

The easiest way is to use the recordset object and et the query to "delete from ... where ..."

AdKerremans
Active Contributor
0 Kudos

.remove works if you first get your record with the .getbykey method.

The help text says: Retrieves and sets the values of the object's properties by the object's absolute key from the Company database.

Answers (1)

Answers (1)

Former Member
0 Kudos

Thank you,

I tried:


Dim oRecordset As SAPbobsCOM.Recordset
        oRecordset = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
        oRecordset.DoQuery("delete From [@MTPS] Where code = '1234' ")

And it seems to work.

I'm just wondering why .remove() exists and how to use it.

Well if I have some more time to spare I can figure it out.

Thanks again

Michiel Kramer

Former Member
0 Kudos

I encourage you to use the usertable object instead of a recordset

myTable.GetByKey("MyCode")
oErroCode=myTable.Remove
if oErroCode<>0 then
  oCompany.GetLastErrorDescription
end if

- SAP may not support a modification of the data in table using the recordset.

- you won't be able to RollBack all the modification performed using a Recordset during a transaction

Sebastien