I want to add a new record and then copy the field DCDate over to the new record, but when I click on the command button it only adds a new record, but didn't copy the DCDate over. Can any body help?
here is my code.
- Private Sub cmdAddNew_Click()
-
-
DoCmd.GoToRecord , , acNewRec
-
[Forms]![frmMedRec]![txtDCDate] = Me.txtDCDate
-
[Forms]![frmMedRec]![cboMRN].SetFocus
-
-
End sub
Thanks
If I understand correctly, this is all on one form.
You have to store the old date in a temporary variable before moving to a new record and then assigning it. Right now what you're doing is assigning the control to itself.
- [Forms]![frmMedRec]![txtDCDate] = Me.txtDCDate
They're both the same thing.
What you're looking for is:
- Private Sub cmdAddNew_Click()
-
-
Dim TempStr As String
-
TempStr = Me.txtDCDate
-
DoCmd.GoToRecord , , acNewRec
-
Me.txtDCDate = TempStr
-
[Forms]![frmMedRec]![cboMRN].SetFocus
-
-
End sub