{"id":47,"date":"2025-06-12T21:14:37","date_gmt":"2025-06-12T21:14:37","guid":{"rendered":"https:\/\/loufab.alwaysdata.net\/blogaccess\/?p=47"},"modified":"2025-08-18T20:47:39","modified_gmt":"2025-08-18T20:47:39","slug":"vba-rechercher-un-mot-dans-toutes-les-requetes","status":"publish","type":"post","link":"https:\/\/loufab.alwaysdata.net\/blogaccess\/index.php\/2025\/06\/12\/vba-rechercher-un-mot-dans-toutes-les-requetes\/","title":{"rendered":"VBA : Rechercher un mot dans toutes les requ\u00eates"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/loufab.alwaysdata.net\/blogaccess\/wp-content\/uploads\/2025\/06\/beagle_snifquery-1024x683.png\" alt=\"\" class=\"wp-image-397\" srcset=\"https:\/\/loufab.alwaysdata.net\/blogaccess\/wp-content\/uploads\/2025\/06\/beagle_snifquery-1024x683.png 1024w, https:\/\/loufab.alwaysdata.net\/blogaccess\/wp-content\/uploads\/2025\/06\/beagle_snifquery-300x200.png 300w, https:\/\/loufab.alwaysdata.net\/blogaccess\/wp-content\/uploads\/2025\/06\/beagle_snifquery-768x512.png 768w, https:\/\/loufab.alwaysdata.net\/blogaccess\/wp-content\/uploads\/2025\/06\/beagle_snifquery-450x300.png 450w, https:\/\/loufab.alwaysdata.net\/blogaccess\/wp-content\/uploads\/2025\/06\/beagle_snifquery.png 1536w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Les modifications d\u2019une application cons\u00e9quente sont souvent difficiles \u00e0 r\u00e9aliser, surtout dans le cas des requ\u00eates. Dans ce billet je vous propose un bout de code pour rechercher un mot, complet ou non, dans toutes les requ\u00eates d\u2019un fichier <strong>MS Access<\/strong>.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"visualbasic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Function SnifQuery(Optional strText As String = \"\") \n   On Error GoTo errSub \n   Dim db As DAO.Database \n   Dim qry As DAO.QueryDef \n\n   Set db = CodeDb \n\n   ' si rien n'est transmis on demande le mot \n   If strText = \"\" Then \n      strText = InputBox(\"Indiquez le mot \u00e0 rechercher dans les requ\u00eates.\" &amp;amp; _ \n           vbCrLf &amp;amp; \"Ce mot peut \u00eatre incomplet.\", \"Mot \u00e0 rechercher\", \"\") \n      If strText = \"\" Then Exit Function \n   End If \n\n   ' balaye toutes les requ\u00eates \n   For Each qry In db.QueryDefs \n      'si on trouve le mot \n      If qry.sql Like \"*\" &amp;amp; strText &amp;amp; \"*\" Then \n         ' on ouvre la requ\u00eate \n         DoCmd.OpenQuery qry.Name, acViewDesign \n      End If \n   Next \n\n   ' on est propre donc on ferme le chose dont on ne se sert plus. \n   Set qry = Nothing \n   Set db = Nothing \n   Exit Function \n   \n   errSub: \n   Resume Next\n \nEnd Function<\/pre>\n\n\n\n<p>Pour le lancement vous pouvez passer par la fen\u00eatre Ex\u00e9cution de <strong>VBE <\/strong>ou encore cr\u00e9er une macro <strong>Autokeys<\/strong>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ouvrez une nouvelle macro.<\/li>\n\n\n\n<li>Affichez la colonne <strong>Nom de macro<\/strong>.<\/li>\n\n\n\n<li>Entrez le raccourci souhait\u00e9. Exemple <strong>+^{Q}<\/strong><\/li>\n\n\n\n<li>Dans la colonne <strong>Action <\/strong>s\u00e9lectionnez <strong>Ex\u00e9cuterCode<\/strong>.<\/li>\n\n\n\n<li>Indiquez dans le nom de la fonction <strong>SnifQuery()<\/strong>.<\/li>\n<\/ul>\n\n\n\n<p>Lorsque vous utiliserez <strong>Ctrl+Shift+Q<\/strong> la fonction sera appel\u00e9e.<\/p>\n\n\n\n<p><strong>Attention ce bout de code ne fait pas de recherche dans les requ\u00eates des biblioth\u00e8ques.<\/strong><\/p>\n\n\n\n<p>Bonne utilisation !<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Les modifications d\u2019une application cons\u00e9quente sont souvent difficiles \u00e0 r\u00e9aliser, surtout dans le cas des requ\u00eates. Dans ce billet je vous propose un bout de code pour rechercher un mot, complet ou non, dans toutes les requ\u00eates d\u2019un fichier MS &hellip; <a href=\"https:\/\/loufab.alwaysdata.net\/blogaccess\/index.php\/2025\/06\/12\/vba-rechercher-un-mot-dans-toutes-les-requetes\/\">Continuer la lecture <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,9,6],"tags":[11,14,7],"class_list":["post-47","post","type-post","status-publish","format-standard","hentry","category-access","category-astuce","category-code-vba","tag-access","tag-astuce","tag-code-vba"],"_links":{"self":[{"href":"https:\/\/loufab.alwaysdata.net\/blogaccess\/index.php\/wp-json\/wp\/v2\/posts\/47","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/loufab.alwaysdata.net\/blogaccess\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/loufab.alwaysdata.net\/blogaccess\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/loufab.alwaysdata.net\/blogaccess\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/loufab.alwaysdata.net\/blogaccess\/index.php\/wp-json\/wp\/v2\/comments?post=47"}],"version-history":[{"count":4,"href":"https:\/\/loufab.alwaysdata.net\/blogaccess\/index.php\/wp-json\/wp\/v2\/posts\/47\/revisions"}],"predecessor-version":[{"id":395,"href":"https:\/\/loufab.alwaysdata.net\/blogaccess\/index.php\/wp-json\/wp\/v2\/posts\/47\/revisions\/395"}],"wp:attachment":[{"href":"https:\/\/loufab.alwaysdata.net\/blogaccess\/index.php\/wp-json\/wp\/v2\/media?parent=47"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/loufab.alwaysdata.net\/blogaccess\/index.php\/wp-json\/wp\/v2\/categories?post=47"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/loufab.alwaysdata.net\/blogaccess\/index.php\/wp-json\/wp\/v2\/tags?post=47"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}