Check number sequence

T

Tina

I have an entry form. Two of the fields are Beginning
Num and Ending Num. The entry for Beginning Num needs to
be one greater than the last entry for Ending Num. Is
there a way to do a check on this?

Thanks for any suggestions,
Tina
 
J

John Spencer (MVP)

Perhaps, Try using the DMAX function to get the largest value in the table and
using that to set the form control's value.

NZ(DMAX("EndingNum","YourTable"),0)+1
 
K

Ken Snell

How do you define "last entry for Ending Num"? Is it a value that is on the
form? Is it a value that is in a table?
 
G

Guest

Let me try to clarify. Beginning Num and Ending Num are
keyed in by the user on one record. What I'm trying to
check for is that the next record's Begining Num is 1
greater than the Ending Num in the previous record.
 
G

Guest

Thanks. I'm not familiar with the DMAX function, but I'll
play around with it to see if it works.
 
K

Ken Snell

OK - this may work then. Put this code on the AfterUpdate event of the
Ending Num control:

Private Sub Ending_Num_AfterUpdate()
Me.[Beginning Num].DefaultValue = """" & (Me.[Ending Num].Value + 1) &
""""
End Sub

This will set the default value of the Beginning Num control to 1 greater
than the value entered in Ending Num, and on the next new record, the number
will automatically fill in.
 
Top