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

Adding new records on a form with a subform

Status
Not open for further replies.

lpgagirl

Technical User
Feb 3, 2003
202
CA
I have a workorders data entry form. It contains a subform where users are to enter technicians assigned to the file and man hours spent on it. It is linked via the workorder ID autonumber field. It works fine except....
when I want to enter a brand new workorder. The fields go blank and an autonumber is generated on the main form (as it should) but there is no blank line (it is datasheet view)
generated on the subform. How can I get a "new record" or blank line generated on the subform when I want to enter a new subform?

Thanks in advance,



Jeannie
 
Jeannie,
You can use the "OnEnter" event of your subform to go to a new record.
In design view of the "mainform" single click the subform and choose "OnEnter"
Choose properties and on the rightside of the "OnEnter" select the three "...". Select "code builder" it will show the first line below and an End Sub;

Code:
Private Sub InvoicesWithSupplier_Subform1_Enter()
DoCmd.GoToRecord , , acNewRec
Forms!DOCTORSTBL1!enterweekly2amounts!dateofentry.SetFocus
End Sub

Copy the two middle lines and replace with your info;
Forms!YourTable!YourSubform!Yourfield.SetFocus
Close and click in, or use the enter key to go to the subform. It SHOULD go to a new record with the cursor in the field you specify.
jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top