Results 1 to 2 of 2
  1. #1
    NJC59 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    2

    Red face Modifying an Access Pass through Query using Querydefs

    Hi there!

    I have looked high and low in order to try and resolve this, but am getting nowhere.

    I have a pass through query which I want to add a parameter to the end.

    The pass through query is very long and has to crate temporary tables on SQL Server in order to generate the required output.

    I do not want to retype or try and paste all of this code into a vba module.

    Can I use querydefs or something in the querydefs collection to extract the code into a new query and append my parameter along the way?

    A simple way of looking at this could be

    querytemplate:-

    "set nocount off



    Select UWREF
    from policy
    where UWREF like '"

    parameter:- (picked up from a text box on a form)
    "ABC123"

    additional text to follow:-
    "%' set nocount on"

    In a nutshell that's all I want to do, but as stated beforehand the real world query has a shed load of other code.

    This is driving me nuts as I can only seem to find examples where the code is manually entered!

    Any help pointers would be greatly appreciated as part of the problem here maybe information overload and I can't believe this that difficult to achieve!

    Cheers,

    Niven

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    If you use LIKE, need wildcard. This is a SELECT sql in VBA procedure? Policy is the pass-through query? Something like:

    "Select UWREF
    from policy
    where UWREF like '*" & Me.textboxname & "*'"

    If you use a combobox and user selects a specific item, can use:
    Where UWREF = '" & Me.textboxname & "'"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Need help Modifying a query expression
    By leslina76 in forum Queries
    Replies: 3
    Last Post: 04-02-2011, 08:45 AM
  2. Replies: 3
    Last Post: 12-28-2010, 12:42 PM
  3. Replies: 3
    Last Post: 11-26-2010, 12:38 PM
  4. CurrentDb.QueryDefs
    By sarnata in forum Queries
    Replies: 3
    Last Post: 09-09-2010, 09:05 AM
  5. Modifying Update Query
    By James Elvin in forum Queries
    Replies: 0
    Last Post: 10-14-2008, 09:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums