How to add new record from form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to add a new record to my form on a click event. The way I'm doing it now works but It overwrites the record and I want to add a new record. This is what I'm doing

intConfirmation = MsgBox("Do you want to enter this test information into the database?", vbYesNo, "Confirmation"
If intConfirmation = vbYes The
[Test History].Form_frmOximeterTest.TestNumber = TestNumber +
[Test History].Form_frmOximeterTest.TestNumber = TestName = cboTestName.Valu
End If
 
Add this line after "If intConfirmation = vbYes Then"

DoCmd.GoToRecord , , acNewRec

This will set it to "Add New" then your next two lines of
code will set the values as you want

HTH, Me.
-----Original Message-----
I want to add a new record to my form on a click event.
The way I'm doing it now works but It overwrites the
record and I want to add a new record. This is what I'm
doing.
intConfirmation = MsgBox("Do you want to enter this test
information into the database?", vbYesNo, "Confirmation")
If intConfirmation = vbYes Then
[Test History].Form_frmOximeterTest.TestNumber = TestNumber + 1
[Test History].Form_frmOximeterTest.TestNumber = TestName = cboTestName.Value
End If
.
 
Back
Top