Solved

Using parameters in SQL passthrough query

Posted on 1998-10-21
1
399 Views
Last Modified: 2011-09-20
I'm using Access 97 and usign a SQL pass through query to pass a paramter - works fine in normal access query, but not in a sql passthrough query.  [Office] is the parameter in the where clause of a select query, which is used by an Access INSERT query

WHERE substring(tblCurrencySeries.CurrencyCode,1,2) =  [Office]

Doesn't seem to work and it doesn't allow me to set the value of the parameter in code
0
Comment
Question by:tomnich
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 7

Accepted Solution

by:
spiridonov earned 100 total points
ID: 1090706
You  can't pass parameters to pass-through query. However, there is a workaround- you  can modify query in VBA and then run it. Here is an example: Stored procedure with parameter executed from pas-through query.

Private Sub Pr_report(report_date as date)
Dim passSQL As QueryDef
Dim sql_txt As String
Dim stDocName As String
Dim db As Database
   
   Set db = CurrentDb()
   Set passSQL = db.QueryDefs("sub_for_configuration_report")
   sql_txt = "EXECUTE rep_configuration  '" & Format$(report_date, "mm/dd/yyyy hh:mm") &"'"
        passSQL.SQL = sql_txt
        passSQL.ReturnsRecords = True
       stDocName = "Report1"
        DoCmd.OpenReport stDocName, acPreview


0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question