Subject Re: Refreshing parameterised IB_Query when params change
Author Marco Menardi <mmenaz@lycosmail.com>
Ok, I will riassume the problem for your and other's convenience:
a) Helen often suggested the BeforeOpen as the ideal place where
assign centrally parameters to queries
b) she said that not only open, but also Refresh will re-opne the
query, so the parameters are used also in refresh
c) I've always used BeforeOpen as she suggested, and was very happy
with this design
d) I've discovered that open is performed on refresh ONLY if
"RefreshAction" is set to raOpen. Yes, it's correct, but this means
that I can't use BeforeOpen and code like "if Active then refresh else
open". To be sure BeforeOpen is fired, I always have to close/open the
query
e) since I've found that having a central place for parameter
assignment is very convenient and better for code manteniance (you
have only one place where to look), and since BeforeOpen seems not to
be the right one, I was asking 1) is there anoter event to use? 2) if
not, what about adding one? or provide a "strong refresh" method that,
whatever the RefreshAction is, closes and opens the query?

thanks
Marco Menardi

--- In IBObjects@yahoogroups.com, Lester Caine <lester@l...> wrote:
> > Well, probably my english is not very good, but I'm sure that if you
> > carefully read my first and second post, you find that IS the problem,
> > i.e. BeforeOpen is fired when you .Refresh ONLY if "RefreshAction" is
> > set to raOpen ;)
>
> Personally that is what I would expect. The BeforeOpen
> trigger will only be fired WHEN the query changes from
> 'NotOpen' to 'Open' state. I do not want it to fire when the
> query is already open, as is the case if the RefreshAction
> is set to maintain it open.
>
> > I've noted following other lists with a news reader, that sometimes
> > seems that the server messes up messages thread, so you could have
> > miss it and I copy it here for your convenience:
> >
> > "Well, refresh does open the query if you set "RefreshAction" to
> > raOpen, but this does not solve complitely the problem, since I often
> > user refresh for "refreshing" the grid content, and I need
> > raKeepDataPos, and when some conditions change (i.e. fiscal year) I
> > need to "refresh" the dataset in the way the new parameters are taken
> > in the query."
>
> In this situation the query will always be open, so that
> BeforeOpen will not ( and should not ) fire. So you need to
> look at what you are doing - I have open master, detail and
> sub-detail, using ParamByName and do not have any problem
> with everthing refreshing when the user makes a change.
>
> So as has been said - what are you trying to do?
>
> The 'BeforeOpen' event should be used to set things like
> database name, user settings and the like - once it has been
> prepared and is in use, then you should be able to change
> the parameters and refresh whenever you like. ( As I
> understand things )
>
> --
> Lester Caine
> -----------------------------
> L.S.Caine Electronic Services