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
'--------------------------