Hello, I need some advice / critique on some code I have written that opens a form. I wrote it so that if there is a current record (i.e. same date and shift) then to go to that record. However, if there is no record, then go to a new record.
It seemed to be working fine for the past two weeks, but suddenly last night I had a user who was somehow able to create 5 new records for yesterday's date and shift. This is the code for the OnClick event from my main form to the input form the user enters their notes into:
Any advice anyone can offer would be appreciated. Thank you.
It seemed to be working fine for the past two weeks, but suddenly last night I had a user who was somehow able to create 5 new records for yesterday's date and shift. This is the code for the OnClick event from my main form to the input form the user enters their notes into:
Code:
Private Sub cmdNotes_Click()
Dim HoldShiftDate As Date
Dim HoldShift As String
HoldShiftDate = Forms!frmSecurity!ShiftDate.Value
HoldShift = Forms!frmSecurity!Shift
If DCount("NotesID", "Notes", "Shift ='" & HoldShift & "'" & _
" AND ShiftDate = #" & HoldShiftDate & "#") > 0 Then
DoCmd.OpenForm "frmQtrNotes", acNormal, , "Shift ='" & HoldShift & "'" & _
" AND ShiftDate = #" & HoldShiftDate & "#"
Else
DoCmd.OpenForm "frmQtrNotes", acNormal
DoCmd.GoToRecord , "frmQtrNotes", acNewRec
Forms!frmQtrNotes!InputDate = HoldShiftDate
Forms!frmQtrNotes!Shift = HoldShift
End If
End Sub
Any advice anyone can offer would be appreciated. Thank you.