CODE
DoCmd.OpenForm "frmCharts", acNormal, , , acFormAdd, acWindowNormal
and the Code Fires but of course I get a No Current record Error 3021 , If the form is opened showing ALL records the Cose works just fine and I am taken to the Record. Is there a way to open the Form (it is recognizing the Duplicate) when the acformAdd button is used in place of viewing ALL records?CODE
Private Sub ChartDate_BeforeUpdate(Cancel As Integer)
'*********************************
'Code sample courtesy of srfreeman
'*********************************
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SID = Me.ChartDate.Value
stLinkCriteria = "[chartdate]=" & "#" & SID & "#"
'Check StudentDetails table for duplicate StudentNumber
If DCount("chartdate", "tblcharts", stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning This Chart Date " _
& SID & " has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", vbInformation _
, "Duplicate Information"
'Go to record of original Student Number
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub
'*********************************
'Code sample courtesy of srfreeman
'*********************************
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SID = Me.ChartDate.Value
stLinkCriteria = "[chartdate]=" & "#" & SID & "#"
'Check StudentDetails table for duplicate StudentNumber
If DCount("chartdate", "tblcharts", stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning This Chart Date " _
& SID & " has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", vbInformation _
, "Duplicate Information"
'Go to record of original Student Number
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub
Thank You