Problem with form when used as subform

IfButOnly

Registered User.
Local time
Tomorrow, 04:59
Joined
Sep 3, 2002
Messages
236
I have a form which loops thru fields and does a simple calculation and accumulation. This works fine as a stand alone form but when I used it as a subform the resultant accumulation is doubled.

For the life of me, i can't see where the problem is so any help would be greatly appreciated.

Sample database attached.
 

Attachments

Peter,

That's not the Stableford system!

Anyway, you've got me way confused here. It works OK, despite the math,
when it is a single form. This is because when you go from round to round,
(meaning record-to-record) you use the form's OnCurrent event to calculate
your Stableford numbers. Good so far.

When you introduce your subform, some weird things happen.

You have a main form based on table1.
You have a subform also based on table1.

When you navigate through the main table (and also the subform's table)
you can not expect to use the subform's OnCurrent event to react to the
main form's actions.

Basically, when you move to the next record on your main form, the
OnCurrent event in your subform is executing TWICE.

Hope that helps, and see ya on the links ...
Wayne
 
Wayne,

Thanks for your reply.

Very cut down and simiplied version of the Db and hence reduced the code for Stableford to make it easier to read.

I understand what you are saying in regards to the subform reacting to the main forms OnCurrent but I am not sure of the options.

The actual subform has over 200 fields spread over tabbed pages and too messy to add into the main form.

Any suggestions??
 
Peter,

That's a lot of fields for some golf scores.

I know that I've seen some golf software here
and other places.

I'll do some research and post here if I find
something.

Wayne
 
Thanks Wayne, but I meant any suggestions to how I refresh the subform (without using the OnCurrent) when I move from record to record on the main form.

Regarding the number of fields - the subform is basically the score card and tracks (for each hole) Par, Index, Score, Putts, Fairways Hit, Greens in regulation, etc... I am quite happy with how it is all looking except for this one problem.

I total about 20 columns on the subform but this is the only one I have a problem with.
 
Peter,

The problem occurrs because you are trying to have a
main form and subform that both point to the same
table. You don't need a subform since there's only
one table.

Using the OnCurrent event to do your calculations is
not your problem. Because of the "strange" way that
you have your forms set up, the OnCurrent event is
firing multiple times.

If you implement any kind of parent/child form
relationships, it should be to support multiple
golfers and courses.

Still looking for examples for you...

Wayne
 
Wayne, I understand what you are saying - one of the reasons why I have it as a subform was that I use the same form in a couple of different forms - with some many fields it make sense to make it a subform so that I would only have to make changes in one spot.

The OnCurrent event in the subform calls the calculation routine which as one of its first actions zeros the fields - so I don't quite understand, even if it is firing it multiple times, why it doubles.

Anyway, nevermind, I have now removed the subforms and the problem.

Many thanks for your help

peter
 

Users who are viewing this thread

Back
Top Bottom