Parent - Child BO and Trying to Update Child


Author
Message
Terry Bottorff
Terry Bottorff
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: 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 (134 views, 21.00 KB)
ScreenShot004.gif (141 views, 14.00 KB)
Replies
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K 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.
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K 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 (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K 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.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K 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 (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K 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

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Edhy beat me to the fix...good job! BigGrin
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Terry Bottorff - 15 Years Ago
Bill Cunnien - 15 Years Ago
Bill Cunnien - 15 Years Ago
Edhy Rijo - 15 Years Ago
Bill Cunnien - 15 Years Ago
                         Your are welcome Bill. :)

Terry, I just noticed that you...
Edhy Rijo - 15 Years Ago
                 Edhy beat me to the fix...good job! :D
Bill Cunnien - 15 Years Ago
Edhy Rijo - 15 Years Ago
Terry Bottorff - 15 Years Ago
Terry Bottorff - 15 Years Ago
Terry Bottorff - 15 Years Ago
                     Hi Terry,

You have to be very careful when using the...
Edhy Rijo - 15 Years Ago
                         Sorry I have been so late on this but I have been working on another...
Terry Bottorff - 15 Years Ago
                             As a follow up. Unless I put the following code after the For each...
Terry Bottorff - 15 Years Ago
                                 Well it is not going to be easy to figure out without a sample, but...
Edhy Rijo - 15 Years Ago
                                     This Child BO is the ContestantsRodeoBO and the parent is the...
Terry Bottorff - 15 Years Ago
                                         Here's what I would do (C#, sorry):

[codesnippet]...
Bill Cunnien - 15 Years Ago
                                             If anyone knows how to get the code spacing/indentation to work...
Bill Cunnien - 15 Years Ago
                                                 I just use html non-breaking space code: ampersand nbsp;

Be...
Greg McGuffey - 15 Years Ago
                                                     This is what I do: [codesnippet] I usually just edit the code in a...
Ivan George Borges - 15 Years Ago
                                                         Hmmm....this didn't work for me. I typed in some text into notepad,...
Greg McGuffey - 15 Years Ago
                                                             Oh, never thought of that... I use Notepad2.exe (...
Ivan George Borges - 15 Years Ago
                                                                 I just tried out notepad2 and it's not keeping tabs/extra spaces...
Greg McGuffey - 15 Years Ago
                                                                     I went the notepad2 route, also. Here is my pasting of code from...
Bill Cunnien - 15 Years Ago
                                                                         Not so good... I am on W7 64bit.

[codesnippet]
public...
Bill Cunnien - 15 Years Ago
                                                                             Annoyingly pragmatic.
Bill Cunnien - 15 Years Ago
                                                                                 I can sell copies of mine... non-refundable. :P
Ivan George Borges - 15 Years Ago
                                                                                     Oh, I bet I know the diff. Yours is probably in Portuguese. :P
Greg McGuffey - 15 Years Ago
                                                                                         Narf!
Bill Cunnien - 15 Years Ago
                                                                                             I want to thank everyone for their help on my parent - child problem....
Terry Bottorff - 15 Years Ago
                                                                                                 This is a great community out here. Thanks for all of your...
Trent L. Taylor - 15 Years Ago
                                                                                                     Related to formatting code in the forum. I just found another method....
Greg McGuffey - 15 Years Ago
Russell Scott Brown - 15 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search