How to make sure form is fully loaded so recordsetclone is correct (1 Viewer)

bignose2

Registered User.
Local time
Today, 15:32
Joined
May 2, 2010
Messages
219
I have a form that has a form footer with totals

I use to use =Sum([Cost]) but this was incredibly slow.

Pleased found much faster way using recordsetclone & adding up via recordset & updating unbound text boxes, great

works well if I press a button but cannot find a way for it to work on initial loading of form.
Trying to avoid timers & such like & over the years always found a way but cannot here.

Form is based on a query in the record source as normal.

If code is in; on load or open or current etc. it errors, error not import because works fine once loaded, must be a lack of or incorrect data, actually recordsetcount shows as 3000, which is ALL the records, once query had time to operate it is in fact 20 or so records that are on the form.

Is there a way to test all data is loaded fully. I have read this many times over the years but never really been stuck with it, always with better coding or planning not been stuck.
 

Isaac

Lifelong Learner
Local time
Today, 08:32
Joined
Mar 14, 2017
Messages
8,738
I wonder if testing the form's RecordsetClone.RecordCount would 'force' them to fully load prior to the test completely executing?
 

Minty

AWF VIP
Local time
Today, 15:32
Joined
Jul 26, 2013
Messages
10,354
Try using a DSum("Field","FormsSavedQuery")
 

bignose2

Registered User.
Local time
Today, 15:32
Joined
May 2, 2010
Messages
219
SOLVED
Hi,

Many thanks for your replies, typical as soon as I asked the question I found the reason it was not working as expected.

From the previous form that opened this new form with calculations, I had some code AFTER the openform command, this code would have run after and in fact had an apply filter so I think the order was rather messed up and had an impact.
I ran the recordset code from the callign form & it was OK.

Now & not really a problem, is to make sure it re-calculates every time anything is changed, would be nice if there was a blanket check, I have quite a few processes that effect this & rather than after update code on every button or field change, I don't think on current etc. is enough but I suspect better coding to be through & do everywhere.

thanks again
 

Isaac

Lifelong Learner
Local time
Today, 08:32
Joined
Mar 14, 2017
Messages
8,738
I don't know if this helps at all, but while there are numerous ways to cause a form to just show "x"-number of records, the way I do it keeps things pretty simple. (I usually do this).
Adjusting the form's Recordsource.
For example, in your situation, you could always just follow that up with a line that counts the recordsetclone's recordcount.
Rather than having to worry if, for example, you used Filter, is that really the same as the recordset--etc.

Anyway - glad you got it working for you.
 

Users who are viewing this thread

Top Bottom