First added record being overwritten by 2nd

thart21

Registered User.
Local time
Today, 13:02
Joined
Jun 18, 2002
Messages
236
I have a main form and subform, with an "Add Records" form opened by a command button on the main form. I want the user to be able to add a record, click on my "Add another record" button and continue until they are done, then hitting the "complete" button which returns them to the main form. But, the first record erases and is replaced by the second, so it is only saving one record.

Here is my code:

Private Sub Additional_Click()

Dim stLinkCriteria As String

' Saves new record and returns to "DocID" field to add another record.

DoCmd.RunCommand acCmdSaveRecord

DoCmd.GoToControl "DocID"

DocID = Null
Revision = Null
Description = Null
DateCompleted = Null
Hours = Null
stLinkCriteria = "[EmployeeID]=" & Me![EmployeeID]
Forms!Employees![Combined Subform].Requery

End Sub

Appreciate any help-Thanks!

Toni
 
Save wasting all that code and put this one line on the click of the button.



All you are effectively doing there is saving the record, and then emptying it, and then saving over it again.

Code:
Private Sub Additional_Click() 

    DoCmd.GotoRecord , , acNewRec

End Sub
 
Thanks for the response, however, this erases the Employee ID as well and I need it to remain on that EE until they close the form. I tried to leave in this code:

stLinkCriteria = "[EmployeeID]=" & Me![EmployeeID]
Forms!Employees![Combined Subform].Requery

But this doesn't save it either.

Any ideas?

Thanks!
 
Code:
Private Sub Additional_Click() 

    Dim lngEmployeeID As Long

    lngEmployeeID = Me.EmployeeID

    DoCmd.GotoRecord , , acNewRec

    Me.EmployeeID = lngEmployeeID

End Sub
 

Users who are viewing this thread

Back
Top Bottom