Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Refresh & AfterScroll
Tue, Oct 3 2006 4:15 PMPermanent Link

"B Miller"
When I call mytable.Refresh, I get an AfterScroll event called for every
record in my table.  Is this the way it is supposed to work?

I refresh queries on the AfterScroll event and I was wondering why it was
taking so long.  It was because the queries were being called 229 times.

Bill

Wed, Oct 4 2006 10:27 AMPermanent Link

Sean McCall
Bill,

Does it definitely happen during the refresh call?
Doesn't sound right unless you are doing something in
TDataset.AfterRefresh or OnCalcFields?

If all else fails, you could try disabling the controls during the refresh.

Seab




B Miller wrote:
> When I call mytable.Refresh, I get an AfterScroll event called for every
> record in my table.  Is this the way it is supposed to work?
>
> I refresh queries on the AfterScroll event and I was wondering why it was
> taking so long.  It was because the queries were being called 229 times.
>
> Bill
>
>
Wed, Oct 4 2006 11:27 AMPermanent Link

"B Miller"
> Does it definitely happen during the refresh call?
Definitely.
> Doesn't sound right unless you are doing something in
> TDataset.AfterRefresh or OnCalcFields?
Yes, I have a calculated field.  If every record's calculated fields are
calculated during a refresh, this is news to me. However, I just checked it
and the AfterScroll event is firing on every record whether I have the
OnCalcFields event assigned or not.

Bill

Wed, Oct 4 2006 11:57 AMPermanent Link

Sean McCall
Bill,

It wouldn't be every record that fire OnCalcFields - just the ones in
the TDataset's buffer. There is no calls that I could see in the code
for TDataset that would fire an AfterScroll on a refresh unless it was
triggered by an event.

Is there any useable call stack when you set a breakpoint in the
AfterScroll event? It may help to link in the source code to the VCL.
Also, if you have MadExcept you could try setting a flag right before
you call refresh & then raise an exception in the after scroll event if
the flag is set. You'll get a call stack right down to the windows API
calls if you do that and I bet it points to some event handler attached
to the TDataset behaving in an unexpected manor.

Good luck tracking it down,

Sean

B Miller wrote:
>> Does it definitely happen during the refresh call?
> Definitely.
>> Doesn't sound right unless you are doing something in
>> TDataset.AfterRefresh or OnCalcFields?
> Yes, I have a calculated field.  If every record's calculated fields are
> calculated during a refresh, this is news to me. However, I just checked it
> and the AfterScroll event is firing on every record whether I have the
> OnCalcFields event assigned or not.
>
> Bill
>
>
Wed, Oct 4 2006 12:41 PMPermanent Link

"B Miller"
Sean,

I found it.  I was using the table as the source for a dropdown lookup
values.  When I refreshed the table, it reloads all the lookup values.
Therefore, every record was hit.  My mistake was that I had the same table
for the lookup that I had as my main datasource and I thought I was just
refreshing the main record.  Thanks for making me look a little harder.

Bill

Wed, Oct 4 2006 3:20 PMPermanent Link

Sean McCall
Glad you found it!

B Miller wrote:
> Sean,
>
> I found it.  I was using the table as the source for a dropdown lookup
> values.  When I refreshed the table, it reloads all the lookup values.
> Therefore, every record was hit.  My mistake was that I had the same table
> for the lookup that I had as my main datasource and I thought I was just
> refreshing the main record.  Thanks for making me look a little harder.
>
> Bill
>
>
Wed, Oct 4 2006 3:41 PMPermanent Link

"B Miller"
> Glad you found it!
Yeah, it was driving me nuts when it was taking 5 seconds or more to show or
switch to the form when I was just calling a simple refresh of the data
record.
Bill

Image