If you just want to store the date that the record was entered or last
modified, just use the BeforeUpdate event of the *form*:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.EntryDate = Date
End Sub
This event fires just before Access saves the record. You can then omit your
Submit2 button, or else just use it it save the record:
RunCommand acCmdSaveRecord
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"hursty" <(E-Mail Removed)> wrote in message
news:19E992AD-3A11-4786-827E-(E-Mail Removed)...
>I am making a defect tracking database and in one of the forms I want to
>keep
> the date after they hit submit so that the person entering data doesn't
> have
> to type in the date everytime. The text box is called EntryDate
> So, to solve that problem I did one of these...
>
> Private Sub Submit2_Click()
> On Error GoTo Err_Submit2_Click
> Dim savedate As Date
> savedate = EntryDate
> DoCmd.GoToRecord , , acNewRec
> Me.EntryDate.SetFocus
> Me.EntryDate = savedate
> Exit_Submit2_Click:
> Exit Sub
>
> Err_Submit2_Click:
> MsgBox Err.Description
> Resume Exit_Submit2_Click
> End Sub
>
> I added the
>
> Dim savedate As Date
> savedate = EntryDate
>
> Me.EntryDate = savedate
>
> to the code so it would save the date.
> This part of it works fine, however, now I have a new problem.
> After submitting the last record, and hitting the 'X' to close, I get the
> following error.
> "The field 'Recrate Reason Table.Reason Code' cannot contain a Null Value
> because the Required property for this field is set to True. Enter a value
> in
> this field"
> I still want Reason Code to be required for all the entries but I don't
> want
> this message to pop up everytime.
> So I tried to figure out some sort of delete record command on Form_close
> but it was to no avail.
> Please Help