Opening subforms in one master form????

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

Guest

Hi all,
Can anyone tell me how to open all all the forms in one window? So I click
on a button a form open within on window?
Thanks
 
Access said:
Can anyone tell me how to open all all the forms in one window? So I click
on a button a form open within on window?

If I understand your request correctly you could create a main form that
has a subform control on it.

Using the "OnClick" event of the appropriate Command Button on this main
form you could modify the SourceObject property of that aforementioned
subform control to the name of the form you want to load. E.G:

Private Sub cmdClientDetail_Click()

With Me!sfcHolder
.SourceObject = "frmClientDetail"
.SetFocus
.Form!BFirst.SetFocus
End With

DoCmd.GoToRecord , , acNewRec

End Sub

Here clicking on the "cmdClientDetail" button on your main form opens
the "frmClientDetail" form in the subform control named "sfcHolder" on
the main form.

The focus is then set to the subform control and then subsequently to
the "BFirst" control on the "frmClientDetail" form.

Finally I go to a new record.

Change these names to appropriate values for your application.

HTH.

--
'--------------------------
' John Mishefske
' UtterAccess Editor
' 2007 Microsoft Access MVP
'--------------------------
 
Hi there,
Thanks for that but I get the following error

"expression to you entered refers to an object that is closed or doesn't
exist"
here is my code

Private Sub CreateNewIssue_Click()
With Me!mycollection (childford)
.SourceObject = "index" (parent form)
.SetFocus
.Form!mycollection.SetFocus
End With

DoCmd.GoToRecord , , acNewRec
End Sub
 
Access said:
Hi there,
Thanks for that but I get the following error

"expression to you entered refers to an object that is closed or doesn't
exist"
here is my code

Private Sub CreateNewIssue_Click()
With Me!mycollection (childford)
.SourceObject = "index" (parent form)
.SetFocus
.Form!mycollection.SetFocus
End With

DoCmd.GoToRecord , , acNewRec
End Sub

"mycollection" should be the name of a *subform control* on your main form.

The key here is to understand that to create a main form - sub form
relationship for the user you must add a *subform control* to the main form.

In the properties of that control - the subform control - you specify a
form object.

Please understand that a form used as a subform is completely different
from a *subform control* - which is a control that can "host" or
"display" another form within its geographical borders.

Your code:
Private Sub CreateNewIssue_Click()
With Me!mycollection (childford)
.SourceObject = "index" (parent form)
.SetFocus
.Form!mycollection.SetFocus
End With

DoCmd.GoToRecord , , acNewRec
End Sub

needs some re-write. First determine the name of the subform control on
your main form. Put the main form in Design View, click on View,
Properties from the menu bar and then click on the subform control - the
area of the main form that holds the subform would be the subform
control. Clicking on it, displaying its Properties and clicking on the
"Other" tab and inspecting the "Name" property should expose the subform
control name.

Regardless, this line is not going to compile:

.SourceObject = "index" (parent form)

since it is not valid VB.

If your code is correct then the "Name" property of this control would
be "mycollection". If it is something else then update the Name property
of the subform control.

Best I can guess is that your code may need to look like this:

Private Sub CreateNewIssue_Click()

With Me!mycollection ' assuming that "mycollection" is
' the name of the subform control
' on the "Me" form.

.SourceObject = "index" ' this would indicate that
'index' is ' the form to load into the subform
' window

.SetFocus ' set focus to the subform control
' first

.Form!mycollection.SetFocus ' set focus to the subform

End With

DoCmd.GoToRecord , , acNewRec ' and expose a new record

End Sub

--
'--------------------------
' John Mishefske
' UtterAccess Editor
' 2007 Microsoft Access MVP
'--------------------------
 
Access said:
Hi John
Could you tell me what the SourceObject is again?

"SourceObject" is a Property of a SubForm Control. Put your form in
design view, click on the subform control. Select View, Properties from
the menu or press F4 in A2007.

Click on the Data tab and the first property is "Source Object". This is
the name of the form that will appear in the subform control as a
subform. Changing this property will cause a new form to load into the
subform control.


--
'--------------------------
' John Mishefske
' UtterAccess Editor
' 2007 Microsoft Access MVP
'--------------------------
 

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

Back
Top