SQL

Is it possible to open an existing access query, modify the criteria
before save and closing using SQL?

I know that I could use SQL to code the query, but I want to make the
changes using SQL and then run a seperate query that is based on the
results of the amended query.
paulmitchell507 [ Di, 01 April 2008 11:37 ] [ ID #1932898 ]

Re: SQL

You can programmatically assign the SQL property of a QueryDef.

Given that the stub of the SQL statement (before the WHERE clause) and the
tail (after the WHERE clause) don't change, you would code it like this:

Dim strWhere As String
Const stcStub = "SELECT * FROM Table1 WHERE "
Const strcTail = " ORDER BY SomeField;"
strWhere = "SomeField = ...
CurrentDb.QueryDefs("Query1").SQL = strcStub & strWhere & strcTail

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"paulmitchell507" <paulmitchell507 [at] googlemail.com> wrote in message
news:47ec6391-2ee2-4c8d-a85b-6d66e6ae4141 [at] p25g2000hsf.google groups.com...
> Is it possible to open an existing access query, modify the criteria
> before save and closing using SQL?
>
> I know that I could use SQL to code the query, but I want to make the
> changes using SQL and then run a seperate query that is based on the
> results of the amended query.
Allen Browne [ Di, 01 April 2008 14:05 ] [ ID #1932899 ]
Datenbanken » comp.databases.ms-access » SQL

Vorheriges Thema: dbhiddenobject doesnt work
Nächstes Thema: Progress bar color