Results 1 to 4 of 4
  1. #1
    Chuck55 is offline Novice
    Windows XP Access 2000
    Join Date
    Apr 2012
    Posts
    25

    set query def using value in a variable

    What is the needed vba to complete the below querydef using the query name inside a variable?

    The ControlTipText property of all controls on an unbound form contains the query name associated with the specific control. Qdf and db are defined using DAO.

    strQuery = ctl.ControlTipText


    Set qdf = db.QueryDefs(<strquery>)

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Try

    Set qdf = db.QueryDefs(strQuery)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Do you mean something like:

    Set qdf = db.QueryDefs(strQuery)

    EDIT: Looks Paul got in 2 minutes before me while I was checking on syntax.
    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.

  4. #4
    Chuck55 is offline Novice
    Windows XP Access 2000
    Join Date
    Apr 2012
    Posts
    25
    Thanks for the replies and my code now works. I feel the yutz though. Before I post my question, I did insert the variable, tried using it with "&" but came up with error 91. After I read the replies I went back to the property containing the query and found I had the query name wrong. I think this post will now allow me to complete the mdb I am making.

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

Similar Threads

  1. Use variable in a Union Query
    By ConfusedMike in forum Queries
    Replies: 4
    Last Post: 09-12-2011, 06:20 PM
  2. Replies: 0
    Last Post: 08-10-2011, 11:59 AM
  3. Replies: 4
    Last Post: 08-05-2010, 01:26 PM
  4. Using a field as a variable in a query
    By Shadow2K9 in forum Queries
    Replies: 1
    Last Post: 06-10-2010, 07:38 PM
  5. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM

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