New Record in subform

  • Thread starter Thread starter Karen
  • Start date Start date
K

Karen

I have a subform which is locked with subform.allowadditions = false.

When I press a "AddNew" command button on the main form, I want to move the cursor to the new record field on the subform.

I have tried this code:
Me.TestContactQuery.Form.AllowAdditions = True
DoCmd.GoToRecord acDataForm, Me.TestContactQuery.Form.Name, acNewrecord

and I've tried this code

Me.TestContactQuery.Form.AllowAdditions = True
DoCmd.GoToRecord acDataForm, "TestContactForm", acNewrecord

In both cases I get the following error

"The object "TestContactForm" is not open.

Any suggestions?
 
To refer to the subform, you need to refer to the subform control on the main form. This is a control that holds the subform. To get the name of this, open the main form in design mode, open the Properties sheet, and click on the subform ONE time. The properties sheet should now show the name of the subform control. If you click a second time you'll be in the subform and the Properties sheet will show the name of the subform, not the control holding it. Once you have that name try:

Me.NameOfSubformControl.Form.AllowAdditions = True
Me.NameOfSubformControl.Form.Recordset.AddNew

--
Wayne Morgan
Microsoft Access MVP


I have a subform which is locked with subform.allowadditions = false.

When I press a "AddNew" command button on the main form, I want to move the cursor to the new record field on the subform.

I have tried this code:
Me.TestContactQuery.Form.AllowAdditions = True
DoCmd.GoToRecord acDataForm, Me.TestContactQuery.Form.Name, acNewrecord

and I've tried this code

Me.TestContactQuery.Form.AllowAdditions = True
DoCmd.GoToRecord acDataForm, "TestContactForm", acNewrecord

In both cases I get the following error

"The object "TestContactForm" is not open.

Any suggestions?
 
Wayne,

Thanks a lot. I had the right subform control name, "TestContactQuery" but I just couldn't get to the new record, your code works super.

Karen
To refer to the subform, you need to refer to the subform control on the main form. This is a control that holds the subform. To get the name of this, open the main form in design mode, open the Properties sheet, and click on the subform ONE time. The properties sheet should now show the name of the subform control. If you click a second time you'll be in the subform and the Properties sheet will show the name of the subform, not the control holding it. Once you have that name try:

Me.NameOfSubformControl.Form.AllowAdditions = True
Me.NameOfSubformControl.Form.Recordset.AddNew

--
Wayne Morgan
Microsoft Access MVP


I have a subform which is locked with subform.allowadditions = false.

When I press a "AddNew" command button on the main form, I want to move the cursor to the new record field on the subform.

I have tried this code:
Me.TestContactQuery.Form.AllowAdditions = True
DoCmd.GoToRecord acDataForm, Me.TestContactQuery.Form.Name, acNewrecord

and I've tried this code

Me.TestContactQuery.Form.AllowAdditions = True
DoCmd.GoToRecord acDataForm, "TestContactForm", acNewrecord

In both cases I get the following error

"The object "TestContactForm" is not open.

Any suggestions?
 
dear Caren
try this:
forms("formMaster").TestContactQuery.Form.AllowAdditions =
True and it will work
Costas
 
Back
Top