Results 1 to 3 of 3
  1. #1
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    670

    Return All Query Names Where Text Like ""

    Is there a way in VBA to search all querydefs and return the name of any query that has "Select field1, field2, field3, field4, field5, field6" in it?

    For example, we have a VERY long process running on a linked SQL Table, and I am trying to track down which access query is the culprit. This would be the fastest way for me to achieve this. Is this possible thorugh VBA?

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    This will read thru all the queries.

    Dim qdf As QueryDef
    For Each qdf in Currentdb.Querydefs
    If Instr(qdf.SQL,"select...") > 0 Then
    ...
    Next

  3. #3
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    While aytee111's suggestion will work, it is dependent on the exact spelling and spacing of your search term.

    You might try similar query with

    Code:
     If qdf.Sql like "*" & "your search string" & "*" then
        debug.print qdf.name & vbcrlf & qdf.sql
     End if

    You have to create the search string to be used.
    Good luck.

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

Similar Threads

  1. return "text" when a table field contains 1
    By rafnews in forum Queries
    Replies: 1
    Last Post: 03-26-2015, 02:04 PM
  2. Replies: 5
    Last Post: 03-22-2013, 01:11 PM
  3. Replies: 2
    Last Post: 11-14-2012, 04:47 PM
  4. Export "Query or Report" to a "Delimited Text File"
    By hawzmolly in forum Import/Export Data
    Replies: 3
    Last Post: 08-31-2012, 08:00 AM
  5. Replies: 3
    Last Post: 06-29-2012, 08:54 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