how do i set a field to be the same as the the previous +1

J

John

I am inputing data via a form and often the first field (BatchNumber) is
sequential. So i need to set the default value to the previous record +1. I
am using the following code BUT it only works for the next record not 3rd 4th
etc.

Private Sub BatchNumber_AfterUpdate()
BatchNumber.DefaultValue = Me.BatchNumber + 1
End Sub

PS I am new to this

JOHN
 
L

luan

I am inputing data via a form and often the first field (BatchNumber) is
sequential. So i need to set the default value to the previous record +1. I
am using the following code BUT it only works for the next record not 3rd 4th
etc.

Private Sub BatchNumber_AfterUpdate()
BatchNumber.DefaultValue = Me.BatchNumber + 1
  End Sub

PS I am new to this

JOHN

Hi !
Try use BeforeInsert event of the form
me.BatchNumber = Dmax("BatchNumber", "Table contents BatchNumber
field") + 1
Other solution: use AutoNumber for this field.
HTH
Luan
 
J

Jason

What about drop down lists in combo boxes - my afterupdates work fine even
if the combo box already contained the exact same text.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top