I have a table called tblseries with a field NextNumber
I also have a form called form1 based on table1 On the form is a control
NNum which I've called NNumtxt with the following code in the BeforeUpdate
Property =NewNbr()
NewNbr is a function in Module1 the code for the function is this
Function NewNbr() As Integer
Dim rst As DAO.Recordset, db As DAO.Database
Dim lngNextNumber As Long
Set db = CurrentDb
Set rst = db.OpenRecordse t("tblSeries" , , dbDenyRead)
With rst
..MoveFirst
..Edit
lngNextNumber = ![NextNumber]
![NextNumber] = lngNextNumber + 1
..Update
End With
rst.Close
Set db = Nothing
End Function
I have seeded the tblseries with the number 1 but when I open my form for a
new record nothing happens just a 0 appears.
Can anyone help here, why doesn't this work? I am using Access2000
Tony
PS With thanks to Hugh O'Neill who posted the original code for another user
I also have a form called form1 based on table1 On the form is a control
NNum which I've called NNumtxt with the following code in the BeforeUpdate
Property =NewNbr()
NewNbr is a function in Module1 the code for the function is this
Function NewNbr() As Integer
Dim rst As DAO.Recordset, db As DAO.Database
Dim lngNextNumber As Long
Set db = CurrentDb
Set rst = db.OpenRecordse t("tblSeries" , , dbDenyRead)
With rst
..MoveFirst
..Edit
lngNextNumber = ![NextNumber]
![NextNumber] = lngNextNumber + 1
..Update
End With
rst.Close
Set db = Nothing
End Function
I have seeded the tblseries with the number 1 but when I open my form for a
new record nothing happens just a 0 appears.
Can anyone help here, why doesn't this work? I am using Access2000
Tony
PS With thanks to Hugh O'Neill who posted the original code for another user
Comment