From: Jeff Freilich on
Hi All

I am trying to set the SQL of a querydef - I can do so using this
code:

CurrentDb.QueryDefs("EDitQuery").SQL = Me.txtSQL.Value
(Where me.txtSQL contains the sql statement.

What I want to do is set the SQL to nothing so it will clear any SQL
in the underlying querydef - and I can open up a blank query editor.
I have tried the following:

Set SQL to "SELECT" - says SELECT is a reserved word and the syntax is
wrong
Set SQL to "" - does not like that either
Set SQL to Null - using a null value variable
Set SQL to Empty - using an empty variable

Nothing seems to work - any thoughts in pointing me in the right
direction would be great

Thanks,

Jeff
From: Benjamins via AccessMonster.com on
Hi Jeff,

You cannot have a Query without any SQL statement. Access wouldn't accept it.
What you can do is to delete the query.

When you want the query, just create the query if it does not exist.

Jeff Freilich wrote:
>Hi All
>
>I am trying to set the SQL of a querydef - I can do so using this
>code:
>
>CurrentDb.QueryDefs("EDitQuery").SQL = Me.txtSQL.Value
>(Where me.txtSQL contains the sql statement.
>
>What I want to do is set the SQL to nothing so it will clear any SQL
>in the underlying querydef - and I can open up a blank query editor.
>I have tried the following:
>
>Set SQL to "SELECT" - says SELECT is a reserved word and the syntax is
>wrong
>Set SQL to "" - does not like that either
>Set SQL to Null - using a null value variable
>Set SQL to Empty - using an empty variable
>
>Nothing seems to work - any thoughts in pointing me in the right
>direction would be great
>
>Thanks,
>
>Jeff

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200912/1

From: Jeff Freilich on
Hello and thanks for the reply

I know that you cannot actually have a query with an SQL statement -
but what I am trying to emulate it if you open a query in the query
editor = go to SQL view and delete all the SQL - when you go back to
the Query Editor you get an empty Editor (and then if you go back to
the SQL view you see: "SELECT;"

Is that possible to emulate or is that just a feature/function of
Acces that puts the "SELECT;" back in to what appears to be an empty
SQL statement?

Thanks

Jeff
From: Douglas J. Steele on
It's not really clear to me what you're trying to do (nor what you mean by
"you cannot actually have a query with an SQL statement", since all queries
ARE SQL statements!)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Jeff Freilich" <jeffto29(a)hotmail.com> wrote in message
news:115f4d28-6a65-4906-90e0-b7f3ca419f9c(a)k29g2000vbi.googlegroups.com...
> Hello and thanks for the reply
>
> I know that you cannot actually have a query with an SQL statement -
> but what I am trying to emulate it if you open a query in the query
> editor = go to SQL view and delete all the SQL - when you go back to
> the Query Editor you get an empty Editor (and then if you go back to
> the SQL view you see: "SELECT;"
>
> Is that possible to emulate or is that just a feature/function of
> Acces that puts the "SELECT;" back in to what appears to be an empty
> SQL statement?
>
> Thanks
>
> Jeff


From: Jeff Freilich on
Sorry Doug

I was responding to the previous post - who said you cant have an
"Empty" SQL statement (I missed the word empty)

WHat I am trying to do is this

I have a query in my database called "EditQuery" - this is really just
a placeholder query - I have a table that stores various SQL
statements that the Admin users can modify/edit/run as needed. I can
easily pass the SQL statement from the table into the
"EditQuery" (once they finish editing the query they will save it and
then I have a process which allows them to save the SQL statement from
"EditQuery" back in to the table.

But where I am stuck is if I want to allow the user to "Add" a new
query - I want to change the "EditQuery" SQL statement to nothing so
that it opens up a blank Query Editory - as if you selected New Query.

Can you pass a null or empty value to QueryDef("EditQuery")? Or is
there a better way to do what I am attempting to do?

I hope I explained it better this time - if not please let me know -
thanks for your assistance

Jeff