Hi...I am using the following code to generate an auto number (taken from previous thread on this forum as always
) problem is the button whcih genartes the autonumber will generate a new number each time clicked within the same record I would like the field to lock after it has been updated for the first time, I have found many threads to enable disable and lock fields but non seem to be working the field with grey aout but can still be updated, would anyone be able to point me in the right direction if it is possible
Private Sub cmdGetNumber_Click()
On Error GoTo Err_cmdGetNumber_Click
Dim NextNo As Long
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("SELECT NextNum FROM tblnextnum")
NextNo = rs!nextnum + 1
'now update the table
rs.Edit
rs!nextnum = NextNo
rs.Update
rs.close
Set rs = Nothing
Me.CRNum = NextNo
Exit_cmdGetNumber_Click:
Exit Sub
Err_cmdGetNumber_Click:
MsgBox Err.Description
Resume Exit_cmdGetNumber_Click
End Sub
cheers...............Fi
Private Sub cmdGetNumber_Click()
On Error GoTo Err_cmdGetNumber_Click
Dim NextNo As Long
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("SELECT NextNum FROM tblnextnum")
NextNo = rs!nextnum + 1
'now update the table
rs.Edit
rs!nextnum = NextNo
rs.Update
rs.close
Set rs = Nothing
Me.CRNum = NextNo
Exit_cmdGetNumber_Click:
Exit Sub
Err_cmdGetNumber_Click:
MsgBox Err.Description
Resume Exit_cmdGetNumber_Click
End Sub
cheers...............Fi