two ways to get this done.
one. write in VBA on load to add a new record then add a value to a txtbox or another object. **remember this will only work on open of the form. you may need to reference this again when anytime you go to a new record.
example(frmcool, one autonumber field, and one text box named "1"
VBA
Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec 'starts with a new record
Me![1] = 1 'put "1" in the text box named [1]
End Sub
----------
Second
write in VBA to calc the new autonumber.
example(form = frmcool,tbl = tblcool )
Function AutoNumberCool() As Long ' ref this function on load.
Dim rst As Object, sql As String, lngMaxNum As Long
Dim lngNewNum As Long
sql = "SELECT Max(tblcool.at) AS MaxNumber" & _
" FROM tblcool;"
' this sql get the max number out of the at field in a table _
[at] was the auto number that would have been used.
Set rst = CurrentDb.OpenRecordset(sql) ' this is different between versions of access
If rst.EOF Then 'check to see if the table has any records
lngNewNum = 1 ' no records start with #1
Else
lngMaxNum = rst!MaxNumber 'with records get max number and
lngNewNum = lngMaxNum + 1 ' start add 1
End If
Me![at] = lngNewNum ' puts the record in the form
End Function
use this code to generate an autonumber in the form every time it's opened, ** remember to ref this when ever a new record is requested to be added to the form.
let me know if this helps or you need more info.
WS