Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating and resetting Line Numbers on a Subform

Status
Not open for further replies.

gpalmer

Technical User
Feb 27, 2002
27
0
0
US
I have created a Form/Subform for patient doctor visist. The subform can have numerous records for each patients particular visit. my tables are VisitMain and VisitDetails. Currently, I have a field in the VisitDetails named Line number that I manually enter in each time I open up a new Patient Visit. I want to somehow start the line number at 001 when I open up a new Patient Visit Record and have it increment for each Line Item. Also, if I open up a new patient Visit record, I want the Line number to start over at 001.

Can anyone help out with ths or point me in the right direction?

Thanks,
Greg
 
Set the default value of the LineNo field on the form to something like:

dmax("LineNo","VisitDetails","VisitorRef=" & me!visitorRef)+1

'Find the highest line number from the details table where the visitor ref is the same as the current one, and add one'

There are other ways, but that should work.

(one of the other ways would be to open a recordsetclone of the subform, find the highest nmubered record (using a sort on the close and movelast?) and add one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top