OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Insert row in subform table with macro

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base
View previous topic :: View next topic  
Author Message
Jack007
General User
General User


Joined: 07 Aug 2009
Posts: 10

PostPosted: Sun Feb 28, 2010 7:45 pm    Post subject: Insert row in subform table with macro Reply with quote

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
View user's profile Send private message
dacm
Super User
Super User


Joined: 07 Jan 2010
Posts: 734

PostPosted: Sun Feb 28, 2010 9:24 pm    Post subject: Reply with quote

Real quick...did you try:

oTrackResultSet.Commit()
oTrackResultSet.Reload


or maybe:

oTrackResultSet.AfterLast
Back to top
View user's profile Send private message
Jack007
General User
General User


Joined: 07 Aug 2009
Posts: 10

PostPosted: Mon Mar 01, 2010 3:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group