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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to make a button that adds a record to a subform

Status
Not open for further replies.

jonvblazen

Technical User
Jun 20, 2001
6
US
I currently have a form that has a subform. The form fills in the information of the subform and what I can't seem to figure out is how to create a button that adds a record to the subform. Any help in this matter is greatly appreciated.
 
In the control buttons click event I would set the focus to the subform by simply using it's name. Then use the to to new record command.

MySubFormName.SetFocus
DoCmd.GoToRecord acActiveDataObject, , acNewRec

Good luck... B-) ljprodev@yahoo.com
ProDev
MS Access Applications
 
Thanks Larry,

But I have a subform that has default values corresponding to combo boxes on the main form. It is refreshed each time the combo boxes is changed...the code you provided, just went to the last record, but I need one to confirm the combo boxes and then adds a record below the one currently being updated. What else might be a solution to this problem?
 
What about an append query? After you set your values with the combo box, trigger an append query to add the record. Then requery the subform. You can either set up an append query using the Query grid, then run the query from VBA or you can write the SQL and use the VBA RunSQL command. If I knew more about your fields and actions I may be able to provide you some sample code or better detail.

B-) ljprodev@yahoo.com
ProDev
MS Access Applications
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top