Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / May 2005

Tip: Looking for answers? Try searching our database.

Passing SQL to QueryDef

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kiloez - 02 May 2005 17:17 GMT
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.
Van T. Dinh - 02 May 2005 17:28 GMT
Check Access VB / DAO Help on the "SQL" Property of the QueryDef object.

Signature

HTH
Van T. Dinh
MVP (Access)

> 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 - 02 May 2005 17:38 GMT
>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 - 02 May 2005 18:54 GMT
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.

> >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
[quoted text clipped - 10 lines]
>
> Richard
Van T. Dinh - 03 May 2005 22:55 GMT
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

Signature

HTH
Van T. Dinh
MVP (Access)

> 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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.