Parent - Child BO and Trying to Update Child


Author
Message
Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)
Group: Forum Members
Posts: 448, Visits: 12K


If EventEntriesRodeoBO1.MoveFirst Then

For Each loRodeo As EventEntriesRodeoBO In Me.EventEntriesRodeoBO1.GetEnumerable



Select Case EventEntriesRodeoBO1.eventCD

Case "BB"

ContestantsRodeoBO1.EventBB = EventEntriesRodeoBO1.eventCD

Case "BR"

ContestantsRodeoBO1.EventBR = EventEntriesRodeoBO1.eventCD

End Select



Next

End If

ContestantsRodeoBO1.Save()ContestantsRodeoBO1.Save()





I am trying to iterate thru the parent(evententriesrodeobo1) and update a column in the child(contestantrodeobo1). This code is called from the click of a button on a form. Please note the attached screenshots. The parent child relationship works on the form so what am I missing in the code? I have traced the code and it seems to be doing what I need it to do except the data does not end up in the child in the database?????

I must be brain dead since this seems to be trivial BUT.?????? TIA
Attachments
ScreenShot003.gif (120 views, 21.00 KB)
ScreenShot004.gif (124 views, 14.00 KB)
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Have you tried moving the Save() method inside the Select/Case statement? I might try something like this:



Select Case EventEntriesRodeoBO1.eventCD

Case "BB"

ContestantsRodeoBO1.Edit()

ContestantsRodeoBO1.EventBB = EventEntriesRodeoBO1.eventCD

ContestantsRodeoBO1.Save()

Case "BR"

etc.



Couple of questions:

Is there a reason that you are checking to see if the Parent BO has moved to the first BO?

Is there only one child BO per parent? If all of the children (assuming one to many) need to be updated, then you may need to iterate them also.



Not sure if this would work...and, I am losing my VB skills. Sorry.
Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Terry,



Basically you are not using the correct object loRodeo as the values. In the For loop you are creating an instance loRodeo for each record in the Me.EventEntriesRodeoBO1 and that is what you have to use, so change your code as follow:





If EventEntriesRodeoBO1.MoveFirst Then

For Each loRodeo As EventEntriesRodeoBO In Me.EventEntriesRodeoBO1.GetEnumerable



Select Case loRodeo.eventCD

Case "BB"

ContestantsRodeoBO1.EventBB = loRodeo.eventCD

Case "BR"

ContestantsRodeoBO1.EventBR = loRodeo.eventCD

End Select



Next

End If

ContestantsRodeoBO1.Save()ContestantsRodeoBO1.Save()



Edhy Rijo

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Wait...one other thing...



Select Case loRodeo.eventCD

Case "BB"

ContestantsRodeoBO1.Edit()

ContestantsRodeoBO1.EventBB = loRodeo.EventCD

ContestantsRodeoBO1.Save()

Case "BR"

etc.
Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Bill,



There is no need to Edit/Save the BO in each case option. The BO will change its EditingState when you assign a value to any of its properties, then do one save out of the FOR loop.

Edhy Rijo

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Edhy beat me to the fix...good job! BigGrin
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
There is no need to Edit/Save the BO in each case option. The BO will change its EditingState when you assign a value to any of its properties, then do one save out of the FOR loop.




Good to know...thanks!
Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Your are welcome Bill. Smile



Terry, I just noticed that you are basically assigning loRodeo.eventCD to "BB" & "BR" events, if that is the case, you can simplify the code by using an IF..ENDIF or a single case "BB","BR" to speed up the process a bit if you need to.

Edhy Rijo

Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
WOW. Thanks for ALL the QUICK replies...... Let me get a grip on what you have replied and I will respond. Thanks again......
Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)
Group: Forum Members
Posts: 448, Visits: 12K


If EventEntriesRodeoBO1.MoveFirst Then

For Each loRodeo As EventEntriesRodeoBO In Me.EventEntriesRodeoBO1.GetEnumerable



Select Case loRodeo.eventCD

Case "BB"

ContestantsRodeoBO1.EventBB = loRodeo.eventCD

Case "BR"

ContestantsRodeoBO1.EventBR = loRodeo.eventCD

End Select



Next

End If



ContestantsRodeoBO1.Save()





I changed my code to the above but still no luck. I did get some info saved in 1 child record. Now the parent is moving but the child record is not? Can that happen? Do I somehow have to navigate to the child record? If so how come the toolbar on the form works?



Also, the relationship is 1 to 1 so I don't have to iterate thru more then 1 child record.

I once had a problem when a parent did not have any records in it so now I can check that with moving to the first record. I know I could use count but this is just something I do.



TIA.



GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search