Incrementing numbers

  • Thread starter Thread starter quixote
  • Start date Start date
Q

quixote

I have a form with Job information. Each job is assigned a
unique number. This form then has a subform with order
information. A job may have multiple orders added to it
over time. What I would like to do is increment the order
number automatically for each job but am unsure of the
best way to do this.
Example:

Job 1000 Job 2000
Order 1 Order 1
Order 2 Order 2
Order 3

How can I increment the orders within each job?

thanks
 
quixote said:
I have a form with Job information. Each job is assigned a
unique number. This form then has a subform with order
information. A job may have multiple orders added to it
over time. What I would like to do is increment the order
number automatically for each job but am unsure of the
best way to do this.
Example:

Job 1000 Job 2000
Order 1 Order 1
Order 2 Order 2
Order 3

How can I increment the orders within each job?

In the BeforeUpdate event of the subform.

If IsNull(Me.OrderNum) = True Then
Me.OrderNum = Nz(DMax("OrderNum", "OrderTable", "JobNum = " &
Me.Parent.JobNum & ""), 0) + 1
End If

The expression broken down essentially says "find the highest Order Number
in the OrderTable where the JobNum is the same as that currently displayed
on the parent form and add 1 to it. The Nz() wrapper gives you a 1 on the
very first entry for a given job.
 
Back
Top