By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,500 Members | 830 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,500 IT Pros & Developers. It's quick & easy.

Open form to new record (autonumber is generated) from another form

P: n/a
Hi all,

This seems like it would be fairly simple, but quite frankly I can't
figure it out. I have combed through other posts and still can't get
it working.

I have two tables (Students, Emergency Contacts) and two seperate main
entry forms for each table (frmNewStudent & frmEmergencyContacts). I
wanted to put a command button on frmNewStudent that when clicked
would open up frmEmergencyContacts to an add new record so that a user
can add a completly new emergency contact record to the Emergency
contact table.

I hope that makes sense.

I haven't been able to get it working. Code I'm currently using is
spitting back the error "Action or method requires a Form Name
argument". Code I have used previously has simply taken me to the
first record in the EmergencyContacts recordset. I just want the form
to ADD a record to EmergencyContacts.

Code in use:

Private Sub Command76_Click()

On Error GoTo Err_Command76_Click

DoCmd.OpenForm frmEmergencyContacts

DoCmd.GoToRecord , , acNewRec

Exit_Command76_Click:
Exit Sub

Err_Command76_Click:
MsgBox Err.Description
Resume Exit_Command76_Click

End Sub

---

Thanks for any help. I'm struggling.

Abby
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Put the name of the form between parentheses:

DoCmd.OpenForm "frmEmergencyContacts", acNormal, , , acFormAdd

The acFormAdd opens it at a new record, this would be little cleaner.

Regards,

GJ

cr**********@yahoo.com (Crispywafers) wrote in message news:<39**************************@posting.google. com>...
Hi all,

This seems like it would be fairly simple, but quite frankly I can't
figure it out. I have combed through other posts and still can't get
it working.

I have two tables (Students, Emergency Contacts) and two seperate main
entry forms for each table (frmNewStudent & frmEmergencyContacts). I
wanted to put a command button on frmNewStudent that when clicked
would open up frmEmergencyContacts to an add new record so that a user
can add a completly new emergency contact record to the Emergency
contact table.

I hope that makes sense.

I haven't been able to get it working. Code I'm currently using is
spitting back the error "Action or method requires a Form Name
argument". Code I have used previously has simply taken me to the
first record in the EmergencyContacts recordset. I just want the form
to ADD a record to EmergencyContacts.

Code in use:

Private Sub Command76_Click()

On Error GoTo Err_Command76_Click

DoCmd.OpenForm frmEmergencyContacts

DoCmd.GoToRecord , , acNewRec

Exit_Command76_Click:
Exit Sub

Err_Command76_Click:
MsgBox Err.Description
Resume Exit_Command76_Click

End Sub

---

Thanks for any help. I'm struggling.

Abby

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.