Strange value from BeforeUpdate code

  • Thread starter Thread starter Slez via AccessMonster.com
  • Start date Start date
S

Slez via AccessMonster.com

I have a subform with the following code:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.BidNumber) Then
Me!BidNumber = Nz(DMax("BidNumber", "Bid", "[ProjectID]"), 0) + 1
End If
End Sub

As new records are added into the subform, it is intended to automatically
number the value in BidNumber 1, 2, 3, 4, 5, and so on. A similar
application in another database, with different fields, works perfectly.
This one, however, always starts with the number 25. It doesn't matter which
ProjectID I'm in, and there doesn't seem to be anything related to that
particular value, yet it always starts with 25, then goes to 26, 27, 28, 29,
and so on.

Does anyone have any thoughts where this peculiar value might be coming from?
Is there anything in my code that would steer it to focus on a value of 24,
resulting in 25 being the first value?

Any suggestions are appreciated!
Slez
 
Slez said:
I have a subform with the following code:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.BidNumber) Then
Me!BidNumber = Nz(DMax("BidNumber", "Bid", "[ProjectID]"), 0) + 1
End If
End Sub

As new records are added into the subform, it is intended to automatically
number the value in BidNumber 1, 2, 3, 4, 5, and so on. A similar
application in another database, with different fields, works perfectly.
This one, however, always starts with the number 25. It doesn't matter which
ProjectID I'm in, and there doesn't seem to be anything related to that
particular value, yet it always starts with 25, then goes to 26, 27, 28, 29,
and so on.

Does anyone have any thoughts where this peculiar value might be coming from?
Is there anything in my code that would steer it to focus on a value of 24,
resulting in 25 being the first value?


You need to compare the ProjectID field to something or
leave it out altogether. If your numbering scheme starts
over for each project, then use something like:
DMax("BidNumber", "Bid", "ProjectID = " & Me.ProjectID)

If the scheme is independent of of the project, then use:
DMax("BidNumber", "Bid")
 
Back
Top