I'm familiar with set values on a linked child from a Parent, however I am wondering if there is a simple way to update a value of a parent record from the child form?
This is not simpler but maybe another way..
In formscript of the child and if i remember the code correctly
thisform.parentform.componens("dsa").value = "test"
or
Thisform.parentform.primaryidocollection.setcurrentobjectplumodifyrefresh("test","test")
I just tried both and I'm getting an error that Object reference not set to an instance of an object. The linked form is a criteria form so even though I am not using a starting and ending value for a range of records is it possible I have to specify which record on the parent form to update?
Please make sure to check if the parent form is not null before accessing the objects to avoid object reference issue.
If (ThisForm.ParentForm IsNot Nothing And ThisForm.ParentForm.Name = "TargetForm") Then ThisForm.PrimaryIDOCollection.SetCurrentObjectPropertyPlusModifyRefresh("Prop", "FromCriteriaForm") End If
In criteria form you can only set the current index of the current ido property. you can filter it in child form and issue a refresh but i dont know if it will cause a problem when the code is coming form the linked form (as the link will move or the setvalues will be incorrect after you move the index?).
below is a sample code to access any open form set/get values ( I didn't test it on my side)
Dim iwsForm As IWSForm = Application.Forms("TargetForm") iwsForm.PrimaryIDOCollection.Filter = "Item = 'test'" iwsForm.PrimaryIDOCollection.Refresh() iwsForm.PrimaryIDOCollection.SetCurrentObjectPropertyPlusModifyRefresh("Prop", "TestValue")
iwsForm.Components("TestCom").Value = "hello" iwsForm.GenerateEvent("FireEvent") iwsForm.Variables("Variable").Value = "TestValue" Dim testString As String = iwsForm.Components("Component").Value
Thank you I will give this a shot!
I am trying to use this logic in another form to pull values from another collection, I receive an error "The given key was not present in the dictionary" if I do not have that form open in the background. If the form is open then I am able to pull the values without issue. If this is not a parent/child form and I am just trying to look up a value from a different collection is the Application.Forms("TargetForm") still the best way or is there another way to look up values?