Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add New Record on a Subform 1

Status
Not open for further replies.

RonMcIntire

Technical User
Oct 12, 2002
166
US
All:

I have a master form with two subforms.

I wish to add a new record to one of the subforms, a non-datasheet subform, with an "add new record button" on the master form.

For the life of me I can't figure out how to do it.

Can anyone help?

Thanks,

Ron
 
If using Continuous Forms
Try this on command button on your Main Form:

Private Sub YourCommandButton_Click()

Me.SubformName.SetFocus
DoCmd.GoToRecord , , acNewRec
Me.SubformName!SomeFieldInYourSubform.SetFocus

End Sub
 
All:

I do have an open subform. The first approach opens another instance. of the subform.

The second approach works fine, however, I have another problem.

My master form has an underlying table of Family names and addresses (a mailing list called FamilyRec) in a one-to-many relationship with a table of individual names called IndivRec. They are connected by a FamilyID (Primary key, no dups).

When I click on the "Add New" cmd button, I get the error "Object doesn't support this property or method." When I single-step through the process, the debugger steps over the last SetFocus statement and jumps to the error message.

I am using A97. Does this procedure not work with A97?

Thanks to you both for your response.

Ron
 
Me![Subform control name].SetFocus

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
All:

The subcontrol name did it. Thanks for all your help. It works like a charm.

Ron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top