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 / Queries / July 2006

Tip: Looking for answers? Try searching our database.

Parameterized Pass-thru query to SQL Server

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Max Yaffe - 20 Jul 2006 03:09 GMT
Dear Group,

I'm using SQL server 2000 with an Access 2003 application utiliting a
DAO/VBA based design.

I want to change my embedded, text based queries to queries in the
query list but I read somewhere that pass-through queries couldn't be
parameterized.

Usually, my query code looks something like this:

(in form MyForm:)
    ...
   Dim RS As Recordset
   Dim strSQL As String
   strSQL = _
       "SELECT * " & _
       " FROM TblQuoteDetail" & _
       " WHERE Quote = '" & Me.Quote & "'"
   Set RS = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset,
                dbSeeChanges, dbOptimistic)
   
    ...'Do something

    Set RS = Nothing

Me.Quote is a field on the current form.  It is a string.

So I want to create a passthru query which pulls the query template
from the query list, patches in the parameter, Me.Quote, and submits
the thing to the server.

What is the right/best/optimum/most maintainable way to code this?

Thanks,
Max
Duane Hookom - 20 Jul 2006 04:06 GMT
If I understand correctly, you can save any pass-through query. Then use you
code like:

Currentdb.QueryDefs("qsptMyPT").SQL = strSQL

Signature

Duane Hookom
MS Access MVP

> Dear Group,
>
[quoted text clipped - 32 lines]
> Thanks,
> Max
Max Yaffe - 20 Jul 2006 20:56 GMT
I want to just create the query in the query design view but how do I
programatically set the parameter?

>If I understand correctly, you can save any pass-through query. Then use you
>code like:
>
>Currentdb.QueryDefs("qsptMyPT").SQL = strSQL
Duane Hookom - 20 Jul 2006 23:09 GMT
I only know of the method that I suggested. You start with a saved P-T query
and modify the SQL property of the P-T to include your parameter values.

Signature

Duane Hookom
MS Access MVP

>I want to just create the query in the query design view but how do I
> programatically set the parameter?
[quoted text clipped - 4 lines]
>>
>>Currentdb.QueryDefs("qsptMyPT").SQL = strSQL
 
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.