I have a module that works but it also needs to update the table so that the next record will advance. Here is the code for the module:
Table that needs to get update after this code runs is EventCounterTable with field NextCustomEventIDCounter getting updated.
The code on my form I am using to update the next counter is: It does not advance the counter in the table though.
Me.newid = GetNextID("EventCounterTable", "NextCustomEventIDCounter") 'Purpose: Increment newid as a counter.
(Module)
Public Function GetNextID(tblName As String, idfieldName As String) As Long
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim lngOut As Long
lngOut = 0
Set db = CurrentDb()
Set rst = db.OpenRecordset("select Max([" & idfieldName & "]) as ID from [" & tblName & "]", dbOpenSnapshot)
If rst.RecordCount > 0 Then
lngOut = rst!id + 1
End If
rst.Close
GetNextID = lngOut