I am executing the attached code on a BO and am experiencing a few issues. #1: The primary key is being created as a -1 or -2 or something funny like that. I have seen this before when you do a NewRow or an Add, but then it creates the proper key on the Save. In this case it is not creating a new key and keeping the negative number.
#2: The new row is not showing up in the SQL query in query analyzer. When I look at the CurrentDataTable after the Save operation it is showing up in there with the -2 PK, but when I run the query directly on the table it is not showing up at all.
Please let me know what I'm doing wrong here. I do the Undo operation at the beginning because the BO is in Edit mode when it gets into this routine. I am just trying to make a temp row that copies the current row and changes a couple of fields. I also tried just doing the Add/Save operation and then an edit because I thought maybe when I copied the ItemArray it was overwriting the PK value somehow, but this still doesn't work.
Public
Sub AddTempRow()
Dim TempRow As Object
Dim TempKey As Integer
TempRow = CurrentRow.ItemArray
Undo(MicroFour.StrataFrame.Business.BusinessUndoType.CurrentRowOnly)
Add()
Save()
Edit()
TempKey = Me.ReportKey
CurrentRow.ItemArray = TempRow
Me.ReportKey = TempKey
Me.ReportDescr = ""
Save()End Sub