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 SkipVought 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 subform from button on main form

Status
Not open for further replies.

bphillips

Technical User
Feb 18, 2003
13
0
0
US
This seems to be a popular question; however, I was unable to find an answer that worked from the other threads in the forum. Given a main form named "MainForm" and a subform displayed in datasheet format on MainForm named "SubForm", what code would one write for a button on MainForm to add a new record to SubForm?
 
There are so many different ways to do this depending on how you've set up your Sub Form, here a 3 common ways.

1. Assuming Allow Additions is set to Yes in the Sub Form
Me!Subform.SetFocus
DoCmd.GoToRecord , , acNewRec

2. Assuming Allow Additions is set to No in the Sub Form
Me!Subform.Form.AllowAdditions = True
Me!Subform.SetFocus
DoCmd.GoToRecord , , acNewRec

3. You could go into Data Entry mode.
Me!Subform.Form.AllowAdditions = True
Me!Subform.Form.DataEntry = True
Me!Subform.SetFocus



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top