Okay...partway there...please help!

KingRudeDog

Registered User.
Local time
Yesterday, 23:44
Joined
May 12, 2006
Messages
36
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!
 
Last edited:
Hmmm, if the sample db you are working with is small enough zip it and post it, that way we can understand better what you are asking.

But it seems to me that you may just have the event wrong for the sub-form.
Change the code (which looks fine) to the "BeforeUpdate" event.

Let us know how you get on. :)
 
Code:
Dim lnVal As Integer

lnVal = Nz(DMax("[SampleId]", "[body_style_data]"), 0) + 1

Me.SampleID = lnVal
 
Lister?

You wouldn't happen to be "Lister D" from mousemod?

Oh and I already tried to zip it and attach...too big. And theres not even any data in it yet..
 
Thanks but...

Variable code just left all new samples at 0....

What Im trying to accomplish:

When the parent form [test_request] creates a new record

I want the NEW <sampleId> values in the table the subform is based off [body_style_data] to reset at 1 and increment up from there.

So request #1 can have "x" amount of samples numbered 1 thru blah...

and then request #2 can have "x" number of samples numbered (sampleId) 1 through blah.
 
use the criteria parameter for the DMax function. This way you will get the max number of all the IDs for this particular object.
 
Meh?

Sorry...

But I'm still somewhat of a newb.

If you could clarify that just a hair...
 
No, thats not me.

Right, wipped up a sample db to work with.

Have a look and see if it sorts your issues. :cool:

If not, see if you can mod it and post back. Think you get the idea mate. :)
 

Attachments

Users who are viewing this thread

Back
Top Bottom