[AccessD] Access 2000 - Filtering SQL Server records

jwcolby jwcolby at colbyconsulting.com
Wed Sep 16 13:01:15 CDT 2009


Stuart,

Thanks, this looks like what I need to get started.

John W. Colby
www.ColbyConsulting.com


Stuart McLachlan wrote:
> You need to use a "pass-through query"  
> 
> To create a *simple* pass-through query:
> 
> Start a new query in Design mode.  Don't select any table.
> 
> With the Design Grid open, Select "Query-SQL Specific-PassThrough" from the main menu.
> The SQL window will open.  Enter the appropriate query, using Transact SQL, not Access 
> SQL,   
> 
> Select Cast(chequenum as int) from tblCheques where PKID = 1
> 
> Click on View-Properties on the main menu. Enter the ODBC connection string (or click on 
> the little selector beside it and select an ODBC data source.
> 
> Now save the query as "qryGetCheckNumber"
> 
> So far so good.  
> 
> The problem comes when you want to use a different PKID,   Pass-through queries can't 
> take parameters :-(.
> 
> To pass a parameter, you need to modify the querydef so you
> need to do something like this before opening the query:
> 
> Public Sub SetChequePKID(PKID As Long)
>    Dim strSQL As String
>    Dim qdf as DAO.QueryDef
>    Dim rs as DAO.Recordset
>    strSQL = "Select Cast(chequenum as int) from tblCheques where PKID" & PKID
>    Set qdf = CurrentDb.QueryDefs("qryGetCheckNumber")
>    qdf.SQL = strSQL
>    qdf.Close
> End Sub
> 



More information about the AccessD mailing list