Subform popup window

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm familiar with using subforms on a main form and using a command button to
open another separate form. How can I open a subform using a command button
and still keep it linked? Is there a wizard for this in 2003? Thanks in
advance.
 
I'm familiar with using subforms on a main form and using a command button to
open another separate form. How can I open a subform using a command button
and still keep it linked? Is there a wizard for this in 2003? Thanks in
advance.

YOu can't. A Subform is a permanent part of a main form; you don't
"open" it.

What you can do is either put it on a second page of a Tab control, so
that you only see the subform when you select that tab page; or set
the subform's Visisble property to False, to make the subform vanish
from view. Set its Visible property back to True with a command button
(and back again to False in the form's Current event).

John W. Vinson[MVP]
 
Thanks I tried both ideas and they work but don't give me the effect I want.
I would really like a form that pops up off the current form.

When I use a command button to popup a form based on a related table I get
an error about no related record in the master table. This leads me to
beleive that if I can retrieve the primary key from the current record in the
parent form, then use that for the default value of the key in the child form
all will be well. How can I do that?

Doug
 
Thanks I tried both ideas and they work but don't give me the effect I want.
I would really like a form that pops up off the current form.

When I use a command button to popup a form based on a related table I get
an error about no related record in the master table. This leads me to
beleive that if I can retrieve the primary key from the current record in the
parent form, then use that for the default value of the key in the child form
all will be well. How can I do that?

It's a bit more work but it's doable.

In the OpenForm code, pass the current form's linking field (the
equivalent of a subform's Master Link Field) in the OpenArgs argument;
also pass a WhereCondition to display only the related records in the
WhereCondition argument. E.g.

DoCmd.OpenForm strFormName, _
WhereCondition := "[ForeignKey] = " & Me!txtPrimaryKey, _
OpenArgs := Me!txtPrimaryKey

Then in the Form's Open event set the default value of the foreign key
field to the OpenArgs argument:

Me.txtForeignKey.DefaultValue = Chr(34) & Me.OpenArgs & Chr(34)

John W. Vinson[MVP]
 
Strange - I thought that you could choose whether to have intergrated or
popup subforms from the Create Form Wizard :)

John Vinson said:
Thanks I tried both ideas and they work but don't give me the effect I want.
I would really like a form that pops up off the current form.

When I use a command button to popup a form based on a related table I get
an error about no related record in the master table. This leads me to
beleive that if I can retrieve the primary key from the current record in the
parent form, then use that for the default value of the key in the child form
all will be well. How can I do that?

It's a bit more work but it's doable.

In the OpenForm code, pass the current form's linking field (the
equivalent of a subform's Master Link Field) in the OpenArgs argument;
also pass a WhereCondition to display only the related records in the
WhereCondition argument. E.g.

DoCmd.OpenForm strFormName, _
WhereCondition := "[ForeignKey] = " & Me!txtPrimaryKey, _
OpenArgs := Me!txtPrimaryKey

Then in the Form's Open event set the default value of the foreign key
field to the OpenArgs argument:

Me.txtForeignKey.DefaultValue = Chr(34) & Me.OpenArgs & Chr(34)

John W. Vinson[MVP]
 
I have been able to accomplish two of the steps to do with the Visible
property (subform visible property to False and Command button to make it
appear), but can't figure out how to get the visible property back to False.
I already have an event on the Main form's 'Current'.
Thanks
 
Back
Top