Hello Frank,
As I understood from the SDK (see DevelopersGuide chapter 13.5.1 section
Parameters) it are the controls that need to be added to some list of
listeners (using com.sun.star.form.XDatabaseParameterBroadcaster) so that
they get resolved when the query runs (done by
com.sun.star.form.XDatabaseParameterListeners).
But I don't understand how it works, the SDK says it doesn't work from
Basic, and I can't find any examples.
- Is this the same parameter listener that you refer to?
Actually I want to achieve the same as you: Filter the database using a
control.
In some cases it may be done using a Subform, I expect. F.i. when filtering
on a discrete value, i.e.
select * from EntryTable with EntryDate = :StartDate
could be done using a subform with a control filled with start dates.
However in my app (time registration) I want to show all the entries for a
project in a certain week or month, so I will need *2* controls to do this
and < and > instead of =.
And you are right a second time:
- it's ok to register listener at the form at the onload event
- but since the exercise is to use the controls as a filter I wouldn't want
to reload the form
- note: MS Access needs a Requery (re-run the query) in this case, which
would be macro command attached to the controls on change event
I really believe that such a simple task as this should be possible without
programming and have always been irritated by MX Access requiring a requery
macro.
Hope you have any suggestions,
Ferry
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: woensdag 9 mei 2007 10:17
To: [email protected]
Cc: Ferry Toth
Subject: Re: 2.1.0 SQL named parameter
Hello Ferry,
please note I answer your mail in [email protected], our
project's maling list. Using this list scales much better than private
mails, so please also answer there [1]. Thanks.
> Sorry for contacting you directly, but I'm searching for an answer to a
> related problem and you seem to be the person with the answers.
>
> Simplified example:
>
>
> I have a table with entries (OpenOffice Base 2.1, jdbc to postgresql
> bridge) with one column called EntryDate.
>
> I want to have a form that limits the entries based on the date.
> This is probably a common task.
>
> The forms query should be something like:
>
> select * from EntryTable with EntryDate > :StartDate and EntryDate <
> :EndDate
>
> Initially Base doesn't recognize the named parameters.
>
> Using http://dba.openoffice.org/howto/param_subst.html, running the
> forms query prompts a dialog box for the parameters StartDate and EndDate.
(Note that nowadays there's an UI for this in the Advanced Settings of
the database. Look in the Edit/Database menu.)
> But what I want to do is have the _data in the controls named StartDate
> and EndDate to_ be substituted. According to the documentation I need
> to register the controls as parameter listeners.
>
> But how do I do this, using Basic?
You cannot register the controls themselves. You can create a listener
in Basic (createUnoListener), and register this listener at the form.
This would need to happen in the OnLoad event of the whole document.
In the listener method, you could then read the values from the
controls, and fill them into the proper parameters.
Note, however, that parameter listeners are only called when the form is
loaded or reloaded. I am not sure whether you want the content of your
form to follow the control content. That is, as soon as you type new
values, the form would be restricted to these new dates.
If so, you'd additionally need to add ModifyListeners to the controls,
and reload the form as soon as the control values change.
> Feature request: Shouldn't these unbound controls be registered
> automatically as parameter listeners? What else would they be good for?
Well, there are quite some other use cases except holding parameter
values, but I agree that it would be nice to be able to *declare* a
control as holding a parameter value.
Somewhat related, and probably would also solve your problem: I'd like
to have the ability to declare a control as "Filter control". Everything
you type in there would be used to filter the respective form in
(nearly) real time ...
> Thanks in advance for your time. I'll try to make an effort to publish
> the solution on a Wiki when solved.
Thanks.
Ciao
Frank
[1] http://wiki.services.openoffice.org/wiki/Base_Mailing_List
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]