Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Passing SQL to QueryDef

11 views
Skip to first unread message

Van T. Dinh

unread,
May 2, 2005, 12:30:21 PM5/2/05
to
Check Access VB / DAO Help on the "SQL" Property of the QueryDef object.

--
HTH
Van T. Dinh
MVP (Access)


"kiloez" <kil...@discussions.microsoft.com> wrote in message
news:58DD37C9-08A1-4F04...@microsoft.com...
> I need to be able to build a SQL string dynamically to pass to a querydef.
> The string will be based on values chosen from a listbox control and/or
other
> controls on a form. Any help would be greatly appreciated. Still
learning.


Richard

unread,
May 2, 2005, 12:38:21 PM5/2/05
to
On Mon, 2 May 2005 09:17:31 -0700, kiloez
<kil...@discussions.microsoft.com> wrote:

>I need to be able to build a SQL string dynamically to pass to a querydef.
>The string will be based on values chosen from a listbox control and/or other
>controls on a form. Any help would be greatly appreciated. Still learning.


Dim db as dao.database
Dim strSQL as string

Set db = Currentdb(()

db.QueryDefs("qryYourQuery").SQL = strSQSL


Something like this should do it.

Richard


kiloez

unread,
May 2, 2005, 1:54:03 PM5/2/05
to
Thanks for the replies so far. I know how to pass the SQL string once it's
built, the problem is building the string dynamically so that for each value
chosen from a given control on a form the SQL string produces a different SQL
string to pass.

Van T. Dinh

unread,
May 3, 2005, 5:55:26 PM5/3/05
to
Not sure whether there is a question in your post but you can code something
like:

strSQL = "SELECT * FROM Table1 " & _
" WHERE MyField = " & Me.MyTextBox
qdf.SQL = strSQL

--
HTH
Van T. Dinh
MVP (Access)


"kiloez" <kil...@discussions.microsoft.com> wrote in message

news:9BA73F60-9D4F-415D...@microsoft.com...

0 new messages