Pass Parameter to Query using Function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chinkyk
    New Member
    • Sep 2006
    • 2

    Pass Parameter to Query using Function

    Hi,

    I Have a query that uses a function for setting the Criteria.
    When I view the return value of the finction it appears to be exactly what I
    want for my criteria. The problem is if I type the criteia directly in the
    query all's well however if I set it to the return value of the function I
    get no records returned. Here's the function I'm using. Any help is appreciated. Thanks!

    Option Explicit
    Public Function GetString() As String
    Dim strName
    strName = "367,1,2"
    End Function

    I want to use GetString() in a Query(attached to a report) in In Clause in Criteria.
    Any help is appreicated. Thanks,
  • PEB
    Recognized Expert Top Contributor
    • Aug 2006
    • 1418

    #2
    Hi my frien,

    What you are trying to do, U can do it only in VB when constructing the SQL/ or query!

    I follow Your Idea! Congrats!!!

    So it's better to create a temporary table in which you stores the values from your list! I see that U don't have pb with VB so maybe U can retrieve your selected items and save them into this temporary table...

    The last step for your query is to write in the criteria clause:

    IN (SELECT [MYFIELDWITHVALU ES] FROM MY-CURRENTTABLE)

    :)

    Best regards!

    Comment

    Working...