Subform data not displayed when mainform opens

R

Ryan

Hi
I have a subform that is filtered by clicking on a value in a combo box in
the main form. The issue I have is that when the main form first opens no
data is displayed until I select something from the combo box. I would like
all data to appear in the subform when the main form opens. Any ideas???
 
J

Jeanette Cunningham

Ryan,
if you open the subform by itself as a separate form does it have records?

Does the main form apply a filter in its open or load event that affects
what shows in the subform? Check the code for this.


Jeanette Cunningham -- Melbourne Victoria Australia
 
J

Jeanette Cunningham

ps,

it's probably worth checking that the Link Master fields and Link Child
fields are set up correctly.


Jeanette Cunningham -- Melbourne Victoria Australia
 
R

Ryan

Hi Jeanette
When I open the subform by itself it gives me all information which is good.

I also took off the link between master and child and the form gave me
everything which is also good. I think this is where the problem may lie
because when I put the link back on it gives me nothing again until I select
a value from the combo box.

My subform is based on a query and in the main form my combo box is unbound
and has it's row source from a field in the query that is used in the
subform. Does this make sense. My aim is to filter the subform from the combo
box in the main form so that users can edit the subform.

Any help is greatly appreciated.
 
J

Jeanette Cunningham

Ryan,
is there a one to many relationship between the table the master form is
based on and the table the child form is based on?
If yes, you should be able to get the link working.

You can create this sort of set up with the form wizard - choose the 3rd
option which allows you to find a value on the form.
Of course include both tables when setting up the wizard so access will
create a form and subform for you.

I use code like this to find all subform records that match the record
selected in the combo on the main form.
Note that subform is the name of the control on the main form that holds the
child form

-------------------------------
If Not IsNull(Me.TheComboName) Then
' Find the record that matches the control.
With Me.Recordset.Clone
.FindFirst "[PrimayrKeyID] = " & Me.TheComboName
If .NoMatch Then
Else
Me.Bookmark = .Bookmark
End If
End With
Me.subform.SetFocus
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top