Results 1 to 2 of 2

Thread: Pass-thru Query

  1. #1
    Join Date
    Jan 2002
    Location
    sheffield, uk
    Posts
    14

    Unanswered: Pass-thru Query

    CAN ANYONE TELL ME HOW TO PASS A VARIABLE TO AN ACCESS 2000 PASS THRU QUERY. MY QUERY RUNS A STORED PROCEDURE ON SQL SERVER THAT EXPECTS 1 VARCHAR PARAMETER, AND I WANT TO PASS THE VALUE OF THE PARAMETER FROM A TEXT BOX ON A FORM. E.G. MY QUERY SYNTAX MAY BE SOMETHING LIKE :-

    EXEC MYSP Forms!Form1!Text1

    BUT THIS DOESN`T WORK.
    THAKNS.
    Mark Davies
    itsmarkdavies@hotmail.com

  2. #2
    Join Date
    Oct 2001
    Location
    Bay Area, CA
    Posts
    117
    I don't think you can pass a form value to a pass-through query. But try build a sql statement in your code and then modify the pass-through query with the function below.

    Function ChangeSQL(strQueryName As String, strSQL As String)
    Dim db As Database
    Dim qryLoop As QueryDef

    Set db = CurrentDb()

    With db
    ' find query and replace SQL
    For Each qryLoop In .QueryDefs
    If qryLoop.Name = strQueryName Then
    qryLoop.SQL = strSQL
    .QueryDefs.Refresh
    End If
    Next qryLoop
    End With

    Set db = Nothing

    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •