| View previous topic :: View next topic |
| Author |
Message |
Jack007 General User

Joined: 07 Aug 2009 Posts: 10
|
Posted: Sun Feb 28, 2010 7:45 pm Post subject: Insert row in subform table with macro |
|
|
I have a form with a subform which is a grid table. With a macro I'm trying to insert a new row in the subform table and then populate the new row. I can read the value of the last ID (Autofield column) before row insertion, but after I inserted the new row, I cannot seem to read the ID of the new row. I continuously read the ID of the previous row.
I have (and I'm not showing all macro code):
aResultSet = oEvent.Source.Model.Parent
.....
oStatement = ThisDataBaseDocument.CurrentController.ActiveConnection.CreateStatement
.....
oTrackResultSet = aResultSet.GetByName("TracksSubForm")
oTrackResultSet.Last
CurTrackRec = oTrackResultSet.getInt(1)
..... This works fine and I read the correct ID
Then I use
oStatement.ExecuteUpdate( "INSERT INTO.....
to successfully insert a new row into the subform table. Now I want to read back the ID of the inserted row, but no statement I try seems to work - I always get back
CurTrackRec . Is there something special I should do to get back the new row ID of a subform? The most obvious to me looks like using:
oTrackResultSet.Reload
oTrackResultSet.Last
NewTrackRec = oTrackResultSet.getInt(1)
but that does not work.
Thanks in advance for any suggestions. |
|
| Back to top |
|
 |
dacm Super User


Joined: 07 Jan 2010 Posts: 734
|
Posted: Sun Feb 28, 2010 9:24 pm Post subject: |
|
|
Real quick...did you try:
oTrackResultSet.Commit()
oTrackResultSet.Reload
or maybe:
oTrackResultSet.AfterLast |
|
| Back to top |
|
 |
Jack007 General User

Joined: 07 Aug 2009 Posts: 10
|
Posted: Mon Mar 01, 2010 3:21 pm Post subject: |
|
|
Dacm - thank you. I tried oTrackResultSet.Commit(), but that gave me the following error: "BASIC runtime error. Property or method not found: Commit"
If tried the following too: Afterlast, updateRow, and similar ones. But I either get this error or it has no effect. I've done the same thing in the main form for fields in the main for and that works great. It seems that the subform needs something additional or different that I don't know what it is.
Thanks. |
|
| Back to top |
|
 |
|