+ Reply to Thread
Results 1 to 2 of 2

Passing Params to Embedded query programmatically

  1. #1
    G
    Guest

    Passing Params to Embedded query programmatically

    Trying to create a loop that refreshes a query with a new parameter each
    loop. I can figured out how to refresh the query by recording a macro, but
    I do not see anything passing a parameter even though a popup form showed
    allowing a parameter entry.

    Any ideas
    Thanx

    Example:
    Dim ParamRange as string
    For i=1 to somenumber

    ParamRange = "A" & i
    parameter value = Range(ParamRange).value
    Refresh query
    copy and paste result to desired worksheet
    Next



  2. #2
    K Dales
    Guest

    RE: Passing Params to Embedded query programmatically

    The result range of the query is a querytable object in VBA, and it has a
    Parameters collection associated with it that can be used to set the
    parameter values, so it would go something like this:

    Dim ParamRange as string
    For i=1 to somenumber

    ParamRange = "A" & i
    With Sheets("QueryTableSheetName").QueryTables("QueryTableName")
    .Parameters("ParameterName").Value = Range(ParamRange).value
    .Refresh
    End With
    copy and paste result to desired worksheet
    Next

    "G" wrote:

    > Trying to create a loop that refreshes a query with a new parameter each
    > loop. I can figured out how to refresh the query by recording a macro, but
    > I do not see anything passing a parameter even though a popup form showed
    > allowing a parameter entry.
    >
    > Any ideas
    > Thanx
    >
    > Example:
    > Dim ParamRange as string
    > For i=1 to somenumber
    >
    > ParamRange = "A" & i
    > parameter value = Range(ParamRange).value
    > Refresh query
    > copy and paste result to desired worksheet
    > Next
    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1