gcdouglass
New member
- Local time
- Today, 02:03
- Joined
- Dec 6, 2019
- Messages
- 8
Have a form. When a new record is created goes to a table to get its numbering and increments a counter. Then prefixes the year the number and populates a text field. So for example 19-240, 19-241 ...
This works in MS Access 2016 and was working in 2019. In version 1808 build 10352.20042 Click to Run the following code no longer runs:
Any help would be appreciated.
This works in MS Access 2016 and was working in 2019. In version 1808 build 10352.20042 Click to Run the following code no longer runs:
Code:
Private Sub Form_BeforeInsert(Cancel As Integer)
Dim rec As Recordset
Set rec = Me.Recordset()
On Error GoTo Form_BeforeInsert_Err
DoCmd.RunSQL "UPDATE [tblNextYearSeqNo] SET SeqNo = SeqNo + 1 WHERE RecordYear = Right(Year(Date()),2); ", -1
Forms!frmIncidentResponse!txtDESIncidentNumber = Right(Year(Date), 2) & "-" & Format(DLookup("[SeqNo]", "tblNextYearSeqNo", "[RecordYear]=Right(Year(Date()),2)"), "0000")
Form_BeforeInsert_Exit:
Exit Sub
Form_BeforeInsert_Err:
If rec.RecordCount = 0 Then
DoCmd.Close acForm, "frmIncidentResponse"
Else
DoCmd.GoToRecord , , acLast
End If
End Sub
Any help would be appreciated.
Last edited: