code

COMP

Registered User.
Local time
Yesterday, 22:26
Joined
Jul 20, 2009
Messages
61
Dim newrec As Integer
DoCmd.GoToRecord , , acLast

newrec = Form_ChangeControl.Number.Value
DoCmd.GoToRecord , , acLast
Form_ChangeControl.Number.Value = newrec + 1
Exit_Command29_Click:

trying to have a field in a form to update the number by 1 in access in the button next record. However the code is not working. Any ideas??
 
Is there some reason you can't use an autonumber for that field?
 
Comp,

Use the form's BeforeInsert event and put:

Me.Number = Nz(DMax("[Number]", "YourTable"), 0) + 1

And set the Property for [Number] on the form to --> Enabled = No

The Nz function provides a value when there are no records.
The DMax retrieves the Maximum value for [Number].
The + 1 increments the value.

Also, Number is a reserved word, you should change it.

Wayne
 
Where is the before insert section?? i Cant seem to find it.

thanks
 

Users who are viewing this thread

Back
Top Bottom