Form in a form

PaulJR

Registered User.
Local time
Today, 05:59
Joined
Jun 16, 2008
Messages
133
I currently have a form (firstform) that contains a button. If I click the button it opens another form (secondform - as a sepated window) that displays data. I use VB (DoCmd.OpenForm "secondform") to open the second form. This works fine.

Now I am trying to insert the secondform into the firstform (I believe in this case the secondform is called a subform?). Problem is, for the life of me I can't work out how to get the second form to work when it is embedded in the firstform. I know this must be really easy to do, but some hint of what I should seach for I'm sure would really help.
 
I placed the design of my second form in my first form, but when I click the button, the second form still pops up as a separate window, and the secondform I have embedded onto my first form does nothing, it is just a blank space.

The code (DoCmd.OpenForm "secondform") I believe is the reason why the secondform still opens up as a separate window. I think I need some code to do this:

OpenForm [firstform].[secondform] - so I can get the secondform to open up inside the firstform. I found help on how to reference forms like this, but I couldn't find anything on how to open a form within a form. Does that make sense?
 
Once you've placed it in your form as a subform, it is, in essence, no longer a "form," but rather a control on your main form. Now, if you want to invoke it in this manner, with a button, you need to use the button to control the Visible Property of the control, instead of opening the form. As a subform, it is already opened when the main form opens.
 
If you've placed the subform within the first form, there's no need to "open" it. It should be there when the first form is opened. Does it show records if opened alone? Did you link a field or fields in it to a field or fields in the main form?
 
Ahh!!.....a subform is a control!! I just tried the following code:

Me![secondform].Requery

and bingo!

Thank you both for your help.
 

Users who are viewing this thread

Back
Top Bottom