Subform "loses" new record

geoB

Registered User.
Local time
Today, 11:32
Joined
Oct 10, 2008
Messages
68
Situation:
I have a form for mothers & babies. There are two combo boxes in the header, one for selecting each. There's also a button for adding a mother. The detail section has two tabs, one for mothers, one for babies. The mothers tab is simply additional fields from the recordset. The babies tab is a subform. When the main form is first opened, all mom names appear in its combo box, all babies names appear in its box. Selecting either one sets the focus on the appropriate record in the proper tab.

Problem:
When a mother is added and its record is saved to add a new baby, the baby subform is opened. The new baby is entered and that record is added. The combo boxes show the names as expected. However, when the new baby's name is selected from the combo box, the subform opens with a blank record. When the baby's mom's name is selected, her record appears properly in the mom tab, but the baby tab is again blank. The form must be closed and reopened for the expected behavior to occur.

There must be a way to code this to get the baby record to appear correctly. I can say that requery doesn't do the trick - at least given the way I've set up the form.

I'll happily provide code as may be useful. Any and all hints or suggestions welcome.

TIA

George
 
I wonder is this is similar to a problem I had. Calling requery wasn't enough. I first had to call

Me.Subform1.sourceObject = "Query.NameOfQuery"

and then call

Me.Subform1.Requery
 
Thanks for the suggestion. I added this to the command on the subform for saving the record. What happened, though, was that the requery cost me references to controls. My code threw an error at a reference to a subform control. Net result was I was further away from my goal!

George
 
Solution found. I love abductive logic = wander around aimlessly hoping for luck or inspiration!

I added "rs.requery" in the babies combo box AfterUpdate event immediately after setting rs=Me.RecordsetClone. I just needed the requery in the right place.

gwb
 

Users who are viewing this thread

Back
Top Bottom