View Full Version : Please help...almost got it.


KingRudeDog
05-12-2006, 11:23 AM
So I almost have this working.

I have a subform <body_style_data> linked to a parent form <test_request>.

I added code to the before_instert function on the subform to give each submitted sample to <body_style_data> an id number <sampleId> starting with 1.

Here is the code...

Me!sampleId = Nz(DMax("[SampleId]", "[body_style_data]"), 0) + 1

and it works great.

But I want it to reset to 1 when the parent form moves to a new record (adding new samples under a new record)

Next line of code please!!!!

So close!

WayneRyan
05-20-2006, 08:46 PM
King,

I would imagine that your subform (subtable) has the Parent form's primary key
in it's table definition.

Me!sampleId = Nz(DMax("[SampleId]", "[body_style_data]", "[ParentID] = " & Me.ParentID), 0) + 1

Wayne

KingRudeDog
05-23-2006, 07:46 AM
worked like a charm...thanks a bunch!