Subject Re: SQL statement not working on the form
From Mervyn Bick <invalid@invalid.invalid>
Date Mon, 31 Aug 2020 10:41:02 +0200
Newsgroups dbase.getting-started

On 2020-08-31 09:00, Gaetano wrote:
>
> Hi Agostinho,
>
> I am attaching an example that works for me using a pushbutton to change
> the SQL statement.
>
> It is important to have a % in the original query else I was getting
> memory access violations when trying to use % in the requery().
>
> The form is under c:\dbasetutorial and the table and memo file under
> c:\dbasetutorial\tables but you can edit the paths in the Form to meet
> your needs (open the form in theĀ  source editor to update paths else you
> may get warning about files not existing)
>
> I will let the experts confirm that this is a valid way.

Stop the bus!  :-)

There are a couple of issues here.

On occasion, for instance where you want to change the display in a grid
from one table to another, it is necessary to change the sql property of
a query.  This should, however, not normally be done.  If you do need to
do it, you need to set the query's active property false, change the sql
string and then set the query's active property true to fetch the new
data for display.

If you need to change the data displayed from the same table either use
a filter or a parameter driven query.   A filter works but it has
limitations.  With a parameter driven query, to fetch new records simply
change the parameter(s) and requery().

Mervyn.