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

creating new record on form with 2 other child subforms

Status
Not open for further replies.

jabrony76

Technical User
Apr 23, 2001
125
US
Hi all,
I'm sure there is an easy way to do this but I sure can't figure it out (hence you probably will notice I don't know how to write code). I have 1 form with 2 other subforms all related by an ID number. I would like to add a button on the form that will allow me to create a new record for the main form and the two subforms. The name of the main form is "Admission Table" and the two subforms are "Admission Urgent/Emergent Subform" and "D/C to HR form" if that helps. I'm using Access 97 as well. I figure I will have to put a command button in and on click event procedure will be involved but I just don't know what to put inbetween the:

Private Sub Command_Click()

End Sub

First of all, am i right about the code? if not, how can I do this. If so, please help me out with the code!
Thanks a bunch!
Andy
 
Can you add data now by clicking Insert-->New Record? If so then put this in as your code:

DoCmd.GoToRecord , , acNewRec

If you can't add a new record currently by click Insert-->New Record then the tables belonging to the subforms are not joined to the main form properly and you will need to look at your Relationships to make sure the tables are related properly.

HTH Joe Miller
joe.miller@flotech.net
 
Joe, I currently have a button to add a new record but when I click it, it just adds a new record for the one subform and no the other. each subform is based on a different table but related by ID#. Can I have a button that will create a new record for both subforms?
Thanks
 
You can set the default value for the control on the subforms containing the idea and reference the main form for the value to place. In the default value property place a line similar to this:

=[Forms]![MyMainFormName]![ID_NumberControlName] Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top