I have a main form and a subform. Everytime a record is added to the subform it will increment by 1. Then when the record is changed on the main form it starts back at 0, so on and so forth. Why doesn't the below work, it just stays at zero?
Private Sub Form_Current()
Dim atonumber As Long
Me.txtauto = atonumber
atonumber = atonumber + 1
I thought that
Dim atonumber As Long would declare the variables. I am new to VBA and learning as I go along but I thought that I can declare in the sub.
Basically, if the subform has records the text field that contains the auto increment will already be number. If the subform has 3 records alreay, the number will start at 3 and if I add a new record then it will increment by +1. When I change the main record another the counter will be a zero if no records are in there.
Right now, what I have when I step through it stays at zero and doesn't increment. When I select a new record the count is still zero.