﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Childform-Problem with Adding more than one record</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Sun, 03 May 2026 22:24:39 GMT</lastBuildDate><ttl>20</ttl><item><title>Childform-Problem with Adding more than one record</title><link>http://forum.strataframe.net/FindPost31866.aspx</link><description>Hi there,&lt;br/&gt;&lt;br/&gt;in a main form I call a form to enter new orders. This form is connected to the&lt;br/&gt;&lt;br/&gt;main form by a child dialog control:&lt;br/&gt;&lt;br/&gt;[code]&lt;br/&gt;&lt;br/&gt;&lt;font face=Consolas&gt;&lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;Dim&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt; aParam(1) &lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;As&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt; &lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;Object&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt;aParam(0) = &lt;/font&gt;&lt;font color=#a31515 face=Consolas&gt;&lt;font color=#a31515 face=Consolas&gt;"N"&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt;aParam(1) = &lt;/font&gt;&lt;font color=#a31515 face=Consolas&gt;&lt;font color=#a31515 face=Consolas&gt;"B"&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt;BestBO1.Add()&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;Me&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt;.ChildKlarneu.ShowDialog(aParam)&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;Me&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt;.ActiveControl = BestGrid&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;[/code]&lt;br/&gt;&lt;br/&gt;In the childform I distinguish between new positions to add and existing positions to edit. When it comes to saving, the code looks like this.&lt;br/&gt;&lt;br/&gt;[code]&lt;br/&gt;&lt;br/&gt;&lt;font face=Consolas&gt;&lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;If&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt; BestBO1.Save &amp;lt;&amp;gt; MicroFour.StrataFrame.Data.&lt;/font&gt;&lt;font color=#2b91af face=Consolas&gt;&lt;font color=#2b91af face=Consolas&gt;SaveUndoResult&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt;.Success &lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;Then&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt;&lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;Dim&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt; cErr &lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;As&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt; &lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;String&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt; = &lt;/font&gt;&lt;font color=#a31515 face=Consolas&gt;&lt;font color=#a31515 face=Consolas&gt;"Fehler beim Speichern!"&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt;mymsgbox(cErr, 48, cProgtitle)&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;Else&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt;&lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;If&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt; &lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;Me&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt;.lNeu &lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;Then&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt;&lt;/font&gt;&lt;font color=#008000 face=Consolas&gt;&lt;font color=#008000 face=Consolas&gt;' Werte zusätzlöich holen&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt;&lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;Me&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt;.putzekuprops()&amp;nbsp; ' Reset some form-properties&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;Me&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt;.Txtkunde.Text = &lt;/font&gt;&lt;font color=#a31515 face=Consolas&gt;&lt;font color=#a31515 face=Consolas&gt;"" ' Reset an unbound field&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt;BestBO1.Add() ' Add a new record This BO is linked between main- and childform&lt;br/&gt;&lt;br/&gt;BestBO1.Refresh()&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;Me&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt;.Refresh()&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;Me&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt;.ActiveControl = txtkollege ' Set focus to the first control&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;Else&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt;&lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;Me&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt;.Close() ' We have choosen the edit-mode&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;End&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt; &lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;If&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt;&lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;End&lt;/font&gt;&lt;/font&gt;&lt;font face=Consolas&gt; &lt;/font&gt;&lt;font color=#0000ff face=Consolas&gt;&lt;font color=#0000ff face=Consolas&gt;If&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;/font&gt;[/code]&lt;br/&gt;&lt;br/&gt;If an existing record is being edited, the form closes. If a new record is saved, the childform, shall stay open and a new record shall be appended and the next position will be entered.&lt;br/&gt;&lt;br/&gt;But this does not work. If i edit a position it works but when I enter a new position, the controls are not&amp;nbsp;refreshed. When I overwrite&amp;nbsp;them with new values and save this record aganin, the same happens.&lt;br/&gt;&lt;br/&gt;When I now leave the childform and look at my grid in the main-form I can see that the first added record has been overwritten and some empty records (one for each new record which was added in my save-routine, see excerpt above).&lt;br/&gt;&lt;br/&gt;What might be going wrong there?&lt;br/&gt;&lt;br/&gt;Best regards &lt;br/&gt;&lt;br/&gt;Thomas</description><pubDate>Tue, 26 Feb 2013 15:17:23 GMT</pubDate><dc:creator>Thomas Holste</dc:creator></item><item><title>RE: Childform-Problem with Adding more than one record</title><link>http://forum.strataframe.net/FindPost31880.aspx</link><description>Thomas,&amp;nbsp;&lt;br/&gt;&lt;br/&gt;&lt;div&gt;Yes, in scenarios that are more complex than just opening the child form once to add a new record and return, it is generally better to call your child dialog explicitly and pass the reference to the business object in the constructor. &amp;nbsp;There is a fair amount of "smoke and mirrors" that goes on with the ChildFormDialog to shuffle the business objects between the forms. &amp;nbsp;There's a lot of pushing and popping of references going on and you will have more control if you implement it yourself.</description><pubDate>Tue, 26 Feb 2013 15:17:23 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Childform-Problem with Adding more than one record</title><link>http://forum.strataframe.net/FindPost31879.aspx</link><description>Hi Edhy,&lt;br/&gt;&lt;br/&gt;thanks a lot for your help, I will try it right now. After testing a whole lot more I think the childformdialog-control is just not capable of doing things like I wanted it to do. In the help-file the examples are limited to adding a record and then returning to the parentform.&lt;br/&gt;&lt;br/&gt;But there are some alternatives I am testing right now like passing the mainform-bo to the childform in the constructor of the childform and then use it. Or by using a separate bo and updating when returning to the mainform.&lt;br/&gt;&lt;br/&gt;Best regards&lt;br/&gt;&lt;br/&gt;Thomas</description><pubDate>Tue, 26 Feb 2013 14:41:53 GMT</pubDate><dc:creator>Thomas Holste</dc:creator></item><item><title>RE: Childform-Problem with Adding more than one record</title><link>http://forum.strataframe.net/FindPost31878.aspx</link><description>Hi Thomas, Ben,&lt;br/&gt;I check your sample and even tried with a DevExpress grid and got the same results, it looks like the BO is being navigated to the top somewhere in the BBS.&lt;br/&gt;&lt;br/&gt;I added some code that will work the way you want, but that is just a simple patch.&amp;nbsp; I believe your logic of trying to add code via the ChildFormDialog all the time, may not be the best way to do this, but anyway here is my code, I simply saving the bo.CurrentRowIndex in the bo.Navigated() and testing for it after adding a new record and navigating to the new record, be aware that I renamed the company textbox to make it clear.&lt;br/&gt;&lt;br/&gt;&lt;span&gt;[codesnippet]&amp;nbsp;&amp;nbsp;&amp;nbsp; Private _currentRowIndex As Integer = 0&lt;br/&gt;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private Sub Save_ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save_ToolStripButton1.Click&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If Me.CustomersBO1.Save() = MicroFour.StrataFrame.Data.SaveUndoResult.Success Then&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.CustomersBO1.Add()&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If Me._currentRowIndex &amp;lt;&amp;gt; Me.CustomersBO1.CurrentRowIndex AndAlso Me._currentRowIndex &amp;gt; 0 Then&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.CustomersBO1.Navigate(MicroFour.StrataFrame.Business.BusinessNavigationDirection.Absolute, Me._currentRowIndex)&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.txtCompany.Focus()&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;br/&gt;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private Sub CustomersBO1_Navigated(e As MicroFour.StrataFrame.Business.NavigatedEventArgs) Handles CustomersBO1.Navigated&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If Me.CustomersBO1.EditingState = MicroFour.StrataFrame.Business.BusinessEditingState.Idle Then&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me._currentRowIndex = Me.CustomersBO1.CurrentRowIndex&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub[/codesnippet]&lt;/span&gt;</description><pubDate>Tue, 26 Feb 2013 11:41:25 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Childform-Problem with Adding more than one record</title><link>http://forum.strataframe.net/FindPost31870.aspx</link><description>Hi Ben,&lt;br/&gt;&lt;br/&gt;there is no sort on the BO. I also set the checkcurrentrowbeforenavigate to&amp;nbsp; False but it did not change anything.&lt;br/&gt;&lt;br/&gt;I have made a little test-app based on the customer-table of the strataframesample-database. Maybe you could have a look what I might be doing wromg.&lt;br/&gt;&lt;br/&gt;Best regards&lt;br/&gt;&lt;br/&gt;Thomas</description><pubDate>Mon, 25 Feb 2013 13:17:49 GMT</pubDate><dc:creator>Thomas Holste</dc:creator></item><item><title>RE: Childform-Problem with Adding more than one record</title><link>http://forum.strataframe.net/FindPost31869.aspx</link><description>&lt;div&gt;It looks like the CurrentRowIndex is never being moved to the new row. &amp;nbsp;Or it is being moved to the new row, and then moved back to the original row.&lt;br/&gt;&lt;br/&gt;There could be a couple of things causing the problem:&lt;div&gt;&lt;br/&gt;&lt;br/&gt;&lt;div&gt;1. &amp;nbsp;If you have a sort on the business object, it can cause problems with Add() in that the underlying DataView will reorder the records after the new row is added. &amp;nbsp;&lt;div&gt;2. &amp;nbsp;There is a broken rule on the first record which is preventing navigation away from the row. &amp;nbsp;Try setting CheckCurrentRowBeforeNavigate = False on the business object to prevent it from aborting navigation when there is a broken rule.</description><pubDate>Mon, 25 Feb 2013 12:58:24 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item></channel></rss>