GoToControl/AllowAdditions

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

Guest

Hi,

I am trying to create a new record in a subform "subA" but I keep getting
the message "There is no field named 'SubA' in the current record". Before
new records are added, the AllowAdditions property of both the main form and
subform are set to false. So far, I haven't changed the AllowAdditions
property for the mainform to true (I've just changed the subform's). It is a
pop up form that creates the new record in the subform.

Here is my code:
(This is from the click event of a button on the pop up form)
(stForm is the mainform and stSubForm is the subform)

Forms(stForm).form(stSubForm).Form.AllowAdditions = True
DoCmd.GoToControl Forms(stForm).Form(stSubForm).Name
DoCmd.GoToRecord , , acNewRec
Forms(stForm).Form(stSubForm).Controls("Box") = 1
Forms(stForm).Form(stSubForm).Form.AllowAdditions = False

It doesn't seem lilke I can set the focus to the subform to create a new
record.

Thanks in advance.
 
You could try referencing a field on your subform using this:

With Forms![stForm]![stSubForm]
SetFocus
.Form![yourfield].SetFocus
End With

hope that helps

DubboPete
 
Thanks, but I found a way to get around it... I'm going to create the new
entry from the pop up form and then just filtered the subform.. this way i
won't have to work with the AllowAdditions property.

Thanks for your suggestion though

DubboPete said:
You could try referencing a field on your subform using this:

With Forms![stForm]![stSubForm]
SetFocus
.Form![yourfield].SetFocus
End With

hope that helps

DubboPete

juicegully said:
Hi,

I am trying to create a new record in a subform "subA" but I keep getting
the message "There is no field named 'SubA' in the current record".
Before
new records are added, the AllowAdditions property of both the main form
and
subform are set to false. So far, I haven't changed the AllowAdditions
property for the mainform to true (I've just changed the subform's). It is
a
pop up form that creates the new record in the subform.

Here is my code:
(This is from the click event of a button on the pop up form)
(stForm is the mainform and stSubForm is the subform)

Forms(stForm).form(stSubForm).Form.AllowAdditions = True
DoCmd.GoToControl Forms(stForm).Form(stSubForm).Name
DoCmd.GoToRecord , , acNewRec
Forms(stForm).Form(stSubForm).Controls("Box") = 1
Forms(stForm).Form(stSubForm).Form.AllowAdditions = False

It doesn't seem lilke I can set the focus to the subform to create a new
record.

Thanks in advance.
 
Back
Top