New Record in subform

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?
 
W

Wayne Morgan

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?
 
K

Karen

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?
 
C

Costas

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

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

Top