I have added an OK button to an invoice form. Users enter invoices on this form. After entering an invoice on this form, I want the user to be able to click an OK button that not only saves the record, but also moves on to a new window where the user could enter the next invoice. My database works fine and I can see that the invoice is populating the InvoiceMaster and InvoiceDetails tables. So really the main problem is that the OK button, when clicked, does not move the user to a blank record where he or she could enter the next invoice. Here is the Event code that is presently in the properties of the OK button (name SaveInvoice):
Private Sub SaveInvoice_Click()
On Error GoTo Err_SaveInvoice_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_SaveInvoice_Click:
Exit Sub
Err_SaveInvoice_Click:
MsgBox Err.Description
Resume Exit_SaveInvoice_Click
End Sub
Private Sub UndoInvoice_Click()
On Error GoTo Err_UndoInvoice_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
Exit_UndoInvoice_Click:
Exit Sub
Err_UndoInvoice_Click:
MsgBox Err.Description
Resume Exit_UndoInvoice_Click
End Sub
Private Sub DeleteInvoice_Click()
On Error GoTo Err_DeleteInvoice_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_DeleteInvoice_Click:
Exit Sub
Err_DeleteInvoice_Click:
MsgBox Err.Description
Resume Exit_DeleteInvoice_Click
End Sub
(You will see that I also have a DeleteInvoice button. The OK button is called SaveInvoice.) I tried adding this code:
CODE
Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
End Sub
When I added this, it did go to a new empty record, but I got an error loop that never ended and I had to restore from backup. Perhaps I added it in the wrong spot. Please assist me with this. Thanks.
Private Sub SaveInvoice_Click()
On Error GoTo Err_SaveInvoice_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_SaveInvoice_Click:
Exit Sub
Err_SaveInvoice_Click:
MsgBox Err.Description
Resume Exit_SaveInvoice_Click
End Sub
Private Sub UndoInvoice_Click()
On Error GoTo Err_UndoInvoice_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
Exit_UndoInvoice_Click:
Exit Sub
Err_UndoInvoice_Click:
MsgBox Err.Description
Resume Exit_UndoInvoice_Click
End Sub
Private Sub DeleteInvoice_Click()
On Error GoTo Err_DeleteInvoice_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_DeleteInvoice_Click:
Exit Sub
Err_DeleteInvoice_Click:
MsgBox Err.Description
Resume Exit_DeleteInvoice_Click
End Sub
(You will see that I also have a DeleteInvoice button. The OK button is called SaveInvoice.) I tried adding this code:
CODE
Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
End Sub
When I added this, it did go to a new empty record, but I got an error loop that never ended and I had to restore from backup. Perhaps I added it in the wrong spot. Please assist me with this. Thanks.