After which event is a subform available

  • Thread starter Thread starter SAC
  • Start date Start date
S

SAC

I have a Main Form and a subform. The main form has a combo box - in the
after update event it looks up a record on the subform.



I would like to make sure the sibform is clear when the main form is opened
and when I click on the * to make a new record. I would like to put code in
to clear the subform, but I'm not figuring out in which event it should go.



In which event should I out the code to clear the subform?



Thanks.
 
In actual fact, the subform loads before the form, so you should be able to
clear it in the parent form's Open event. If that doesn't work, then the
Load event should for sure.
 
Thanks, Doug!

How do I work around clear a control that's bound to a primary key field?
It won't let me assign a value (Null) to it, of course.

Thanks for your help.
 
If there's legitimate data for the subform, why do you want to clear it?
Have you set the LinkMasterFields and LinkChildFields appropriately?

As to your other question, the form's Current event fires when you move to a
new record.
 
It's probably a design flaw on my part. I'd rather do the Link
Master/Child.

Right now it's not set becasue the main form's combo box's after update
event doesn't lookup and display the record on the subfom when I have the
Link set. I like it to find it after the combo box updates and display it.
Also, I'd like it to work similarly on the not in list event when I add a
record to the combo box......so...I've been wrestling with doing it
manually...something I don't like to do when access has the functionality
built into it.

Oh, when I make a change to the combo box the subform does show the correct
record after I move to a different record on the main form and then come
back...then it displays the correct record.

What do I need to do to make this work?

Thanks.
 
I suppose you could put code in the combo box's AfterUpdate event to set an
appropriate filter for the form being used as the subform. To set a filter
on that form from the parent form, you'd use

Me.NameOfSubformControl.Form.Filter = "...."
Me.NameOfSubformControl.Form.FilterOn = True

Depending on how you added the form as a subform, the name of the subform
control on the parent form may be different than the name of the form being
used as a subform.
 
How could I use the Link Master/Child? It works OK when I navigate to a
different record and then back...the correct record shows up in the subform,
but when it doesn't show up when the after update event triggers from the
combo box.

Any ideas on this?
 
Is the combo box bound or unbound?

The Link Master/Child fields refer to fields in the underlying recordsets of
the two forms, not unbound controls.
 
Yes it's bound and the Link Master/Child is setup correctly with fields in
the underlying recordsets of the two forms.

I think I understand the problem, but not sure what to do about it....

The Main Form is for Events. The subform is for facility.

The Main Form's combo box shows the name of the facility and the subform (on
a tabbed form) shows the details of the facility.

Since the main form events can be at the same facility, then it's the "many"
side, and the subform is the one, showing the details the THE facility where
this particular event is taking place.

So I have to do a manual lookup some way, don't I?

Thanks for your help....!!



The main form
 
Back
Top