Solved Auto fill serial number in subform (1 Viewer)

theinviter

Registered User.
Local time
Today, 12:34
Joined
Aug 14, 2014
Messages
241
Dears;
I have created a form "Clinic" and sub from "Delivery_Number" , there is a field named "Delivery" , user update "Delivery_Date"
so I want this field "Delivery" to auto update with serial number starting from (one) after updating "Delivery_Date".
repeat the cycle with every new record in main form.

anu advise.

thanks
 

bob fitz

AWF VIP
Local time
Today, 20:34
Joined
May 23, 2011
Messages
4,727
In the forms Update event, you could use DMax() function to get the last used number, add 1 to it and save the result in the appropriate field.
 

bob fitz

AWF VIP
Local time
Today, 20:34
Joined
May 23, 2011
Messages
4,727
In the forms Update event, you could use DMax() function to get the last used number, add 1 to it and save the result in the appropriate field.
Just a further thought. You would need to make sure that the field has not already got a value before assigning the value, otherwise editing an existing record would cause the number to be altered.
 

theinviter

Registered User.
Local time
Today, 12:34
Joined
Aug 14, 2014
Messages
241
Just a further thought. You would need to make sure that the field has not already got a value before assigning the value, otherwise editing an existing record would cause the number to be altered.
thanks
but what if a new record in subform has a new ID of main form, then wanna cycle start again from one .
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:34
Joined
Feb 19, 2002
Messages
43,297
Here's a sample that shows two types of custom sequence numbers. You want the type in the form to the right which is a subform.

 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 14:34
Joined
Feb 28, 2001
Messages
27,192
Are you attempting to create a CHILD record number that is unique for a given parent record? Or was it the PARENT record that needs to be numbered specially? Or both?
 

theinviter

Registered User.
Local time
Today, 12:34
Joined
Aug 14, 2014
Messages
241
Done,
i did as the code below, worked fine.
If Me.Delivery = 0 Then
Delivery = Nz(DMax("Delivery", "PO_Date", " Link_ID = " & Forms!Data_Entry!ID), 0) + 1
Else
End If
 

Users who are viewing this thread

Top Bottom