RE: Requery on command button not working



Hi, Steve.

Please post the VBA for the command button, GetYear( ) and GetPeriod( )
functions, the Record Source of the form (if this is defined in the pop-up
form, then post that VBA call), and the data types of any relevant fields.
Is there a subform involved? Are these calculations coming from "across the
network" (i.e., development on a file not on your own workstation)? Is this
a shared database? Is Auto Name Correct turned on? Are subdatasheets turned
on for this table or any related tables?

> the form is doing nothing
> other than some conditional formatting on about 7 fields (there are some 50
> rows displayed however). The screen displays quite quickly on entry so I
> don't think it can be that that causes it.

One way to test this is to make a copy of the form and remove this
conditional formatting from the copy, then use the copy to see whether the
"Calculating..." still takes too long.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.


"Ace9x" wrote:

> The calculation message is on permanently, and the form is doing nothing
> other than some conditional formatting on about 7 fields (there are some 50
> rows displayed however). The screen displays quite quickly on entry so I
> don't think it can be that that causes it. It is the first time in some 50
> forms I have built that this has occurred.
> When I attempt to use the command button to display the previous period the
> screen just freezes out completely even with your suggested code. This
> indicates some other problem I cannot figure out. The form is built on a
> temporary table that is already populated prior to invoking and has only 160
> rows currently.
>
>
>
> "'69 Camaro" wrote:
>
> > Hi, Steve.
> >
> > > First problem I have encountered is that a 'Calculating ....' message is
> > > displayed at the bottom of the Access screen
> >
> > The CPU is busy executing your request. This requires math calculations by
> > the CPU. Hence, the message.
> >
> > > not seen this before
> >
> > Your CPU is so fast that by the time the Status Bar could be updated, the
> > calculation is done, so there's no need for the message. Whatever the
> > current request is for the CPU to execute, it's taking some time to finish,
> > so the Status Bar has time to update you and advise you what it's doing,
> > calculating.
> >
> > > Second problem is that the requery doesn't call the data up correctly
> >
> > Try:
> >
> > intYear = GetYear(1)
> > intPeriod = GetPeriod(1)
> > varwhere = "Period = " & intPeriod & " AND [Year] = " & intYear
> > Me.Filter = varwhere
> > Me.FilterOn = True
> >
> > And I would advise against using Reserved words, such as Year, when naming
> > items. It will result in buggy applications.
> >
> > HTH.
> > Gunny
> >
> > See http://www.QBuilt.com for all your database needs.
> > See http://www.Access.QBuilt.com for Microsoft Access tips.
> >
> > (Please remove ZERO_SPAM from my reply E-mail address so that a message will
> > be forwarded to me.)
> > - - -
> > If my answer has helped you, please sign in and answer yes to the question
> > "Did this post answer your question?" at the bottom of the message, which
> > adds your question and the answers to the database of answers. Remember that
> > questions answered the quickest are often from those who have a history of
> > rewarding the contributors who have taken the time to answer questions
> > correctly.
> >
> >
> > "Ace9x" wrote:
> >
> > > I have a form built on a temporary table which is using Year/Period to
> > > differentiate between records. On accessing the form the current period data
> > > is displayed (uses a varwhere statement containing the year and period values
> > > created in a pop-up form to then call this form).
> > > At the bottom of the form I have 10 command buttons, one for the current
> > > period and one for the 9 preceeding periods. When pressing one of these
> > > buttons the intention is to display the releveant data for that period. The
> > > code inside each button builds the varwhere statement with the selected
> > > period and then issues a Me.Requery. This does not populate the data as I
> > > intended.
> > >
> > > First problem I have encountered is that a 'Calculating ....' message is
> > > displayed at the bottom of the Access screen - not seen this before,and
> > > nothing I have invoked in the form should be causing this to happen as far as
> > > I am aware. This appears to stall the screen and I need to move focus out of
> > > the form (to the internet or something else) and then back into the form to
> > > action anything on the screen (scrollbar etc).
> > >
> > > Second problem is that the requery doesn't call the data up correctly, just
> > > leaves the data as for the original varwhere entry from the popup. I have
> > > missed something out or I am not applying the correct logic somewhere but
> > > cannot see the wood for the trees so to speak.
> > >
> > > Code used in Command button On Click is shown below :-
> > >
> > > intYear = GetYear(1)
> > > intPeriod = GetPeriod(1)
> > > varwhere = "ztblA.Period = " & intPeriod & " AND ztblA.Year = " & intYear
> > > Me.Requery
> > > 'DoCmd.ApplyFilter , varwhere (tried this as well)
> > >
> > > GetPeriod calculates the filtered original value sent to the form minus the
> > > value in quotes. GetYear checks for a change in year (only occurs when near
> > > start of Financial year). Both use simple IF statements only to return values.
> > >
> > >
> > > Comments, help or info gladly appreciated.
> > >
> > > Cheers,
> > > Steve
> > >
> > >
> > >
> > >
.