<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to pass combobox's value to a variable  on a query python addin toolbar in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-pass-combobox-s-value-to-a-variable-on-a/m-p/752646#M320</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/397952"&gt;Sergio Pizarro&lt;/A&gt;‌,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The 3rd argument to the arcpy.MakeFeatureLayer_management() method is a where clause in SQL syntax. In your sample code you have:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;query = [County] = fc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This line of code is not a valid SQL syntax, nor is it valid Python syntax.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this case, the query variable must be a string, so you should put single quotes around the clause.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a doc which goes into SQL syntax for where clauses in more detail:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/help/mapping/navigation/sql-reference-for-elements-used-in-query-expressions.htm"&gt;https://pro.arcgis.com/en/pro-app/help/mapping/navigation/sql-reference-for-elements-used-in-query-expressions.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Go ahead and try that. In the meantime I'm going to move your post to the Python community space for you to hopefully get more help on this if needed:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/community/developers/gis-developers/python/content"&gt;https://community.esri.com/community/developers/gis-developers/python/content&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 18 Apr 2020 00:26:36 GMT</pubDate>
    <dc:creator>AmyNiessen</dc:creator>
    <dc:date>2020-04-18T00:26:36Z</dc:date>
    <item>
      <title>How to pass combobox's value to a variable  on a query python addin toolbar</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-pass-combobox-s-value-to-a-variable-on-a/m-p/752645#M319</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;Trying to capture a variable from a combobox and use it on SQL query, but it doesn´t work.&lt;/P&gt;&lt;P&gt;Any idea how to create the variable "query"?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;import pythonaddins&lt;BR /&gt;arcpy.env.workspace = r'C:/Users//Documents/Work/Access Resource/Propiedad Minera/Tools/PMdata.mdb'&lt;BR /&gt;arcpy.env.overwriteOutput = True&lt;BR /&gt;arcpy.env.addOutputsToMap = True&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;query = [County] = fc&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;class ButtonClass2(object):&lt;BR /&gt; """Implementation for Test3_addin.button_1 (Button)"""&lt;BR /&gt; def __init__(self):&lt;BR /&gt; self.enabled = True&lt;BR /&gt; self.checked = False&lt;BR /&gt; def onClick(self):&lt;BR /&gt; arcpy.MakeFeatureLayer_management("Properties","County_Layer",query)&lt;/P&gt;&lt;P&gt;class ButtonClass3(object):&lt;BR /&gt; """Implementation for Test3_addin.button_2 (Button)"""&lt;BR /&gt; def __init__(self):&lt;BR /&gt; self.enabled = True&lt;BR /&gt; self.checked = False&lt;BR /&gt; def onClick(self):&lt;BR /&gt; pass&lt;/P&gt;&lt;P&gt;class ComboBoxClass1(object):&lt;BR /&gt; """Implementation for Test3_addin.combobox (ComboBox)"""&lt;BR /&gt; def __init__(self):&lt;BR /&gt; self.items = ["Orange",Hiils&amp;nbsp;""]&lt;BR /&gt; self.editable = True&lt;BR /&gt; self.enabled = True&lt;BR /&gt; self.dropdownWidth = 'WWWWWW'&lt;BR /&gt; self.width = 'WWWWWW'&lt;BR /&gt; def onSelChange(self, selection):&lt;BR /&gt; print"New Selection:",selection&lt;BR /&gt;fc =selection&lt;BR /&gt; def onEditChange(self, text):&lt;BR /&gt; pass&lt;BR /&gt; def onFocus(self, focused):&lt;BR /&gt; if focused: &lt;BR /&gt; self.mxd = arcpy.mapping.MapDocument('current') &lt;BR /&gt; layers = arcpy.mapping.ListLayers(self.mxd) &lt;BR /&gt; self.items = [] &lt;BR /&gt; for layer in layers: &lt;BR /&gt; self.items.append(layer.name)&lt;BR /&gt; def onEnter(self):&lt;BR /&gt; pass&lt;BR /&gt; def refresh(self):&lt;BR /&gt; pass&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2020 16:54:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-pass-combobox-s-value-to-a-variable-on-a/m-p/752645#M319</guid>
      <dc:creator>SergioPizarro</dc:creator>
      <dc:date>2020-03-20T16:54:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass combobox's value to a variable  on a query python addin toolbar</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-pass-combobox-s-value-to-a-variable-on-a/m-p/752646#M320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/397952"&gt;Sergio Pizarro&lt;/A&gt;‌,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The 3rd argument to the arcpy.MakeFeatureLayer_management() method is a where clause in SQL syntax. In your sample code you have:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;query = [County] = fc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This line of code is not a valid SQL syntax, nor is it valid Python syntax.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this case, the query variable must be a string, so you should put single quotes around the clause.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a doc which goes into SQL syntax for where clauses in more detail:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/help/mapping/navigation/sql-reference-for-elements-used-in-query-expressions.htm"&gt;https://pro.arcgis.com/en/pro-app/help/mapping/navigation/sql-reference-for-elements-used-in-query-expressions.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Go ahead and try that. In the meantime I'm going to move your post to the Python community space for you to hopefully get more help on this if needed:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/community/developers/gis-developers/python/content"&gt;https://community.esri.com/community/developers/gis-developers/python/content&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Apr 2020 00:26:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-pass-combobox-s-value-to-a-variable-on-a/m-p/752646#M320</guid>
      <dc:creator>AmyNiessen</dc:creator>
      <dc:date>2020-04-18T00:26:36Z</dc:date>
    </item>
  </channel>
</rss>

