       <cfset basQual = " #basQual# AND tbl_left_gonad_width.attribute_value #oper# '#schTerm#'">
     </cfif>
   </cfif>
+</cfif>
 </cfif>
 
 <cfif isdefined("location_in_host") and len(location_in_host) gt 0>
   <cfset mapurl = "#mapurl#&location_in_host=#location_in_host#">
-  <cfset basJoin = " #basJoin# INNER JOIN v_attributes tbl_location_in_host ON (#session.flatTableName#.collection_object_id = tbl_location_in_host.collection_object_id)">
-  <cfset basQual = " #basQual# AND tbl_location_in_host.attribute_type = 'location in host'">
-  <cfif session.flatTableName is not "flat"><cfset basQual = " #basQual# AND tbl_location_in_host.is_encumbered = 0"></cfif>
-  <cfif location_in_host neq "_">
+  <cfif compare(location_in_host,"NULL") is 0>
+      <cfset basQual = " #basQual# AND ConcatAttributeValue(flat.collection_object_id,"location_in_host") is null">
+  <cfelse>
+    <cfset basJoin = " #basJoin# INNER JOIN v_attributes tbl_location_in_host ON (#session.flatTableName#.collection_object_id = tbl_location_in_host.collection_object_id)">
+    <cfset basQual = " #basQual# AND tbl_location_in_host.attribute_type = 'location in host'">
+    <cfif session.flatTableName is not "flat"><cfset basQual = " #basQual# AND tbl_location_in_host.is_encumbered = 0"></cfif>
+    <cfif location_in_host neq "_">
     <cfset oper=left(location_in_host,1)>
     <cfif listfind(charattrschops,oper)>
       <cfset schTerm=ucase(right(location_in_host,len(location_in_host)-1))>

      <cfset basQual = " #basQual# AND tbl_weight.attribute_value #oper# '#schTerm#'">
    </cfif>
  </cfif>
</cfif>

<cfif isdefined("wing_chord") and len(wing_chord) gt 0>
  <cfset mapurl = "#mapurl#&wing_chord=#wing_chord#">
  <cfset basJoin = " #basJoin# INNER JOIN v_attributes tbl_wing_chord ON (#session.flatTableName#.collection_object_id = tbl_wing_chord.collection_object_id)">
  <cfset basQual = " #basQual# AND tbl_wing_chord.attribute_type = 'wing chord'">
  <cfif session.flatTableName is not "flat"><cfset basQual = " #basQual# AND tbl_wing_chord.is_encumbered = 0"></cfif>
  <cfif wing_chord neq "_">
    <cfset schunits="">
    <cfset oper=left(wing_chord,1)>
    <cfif listfind(numattrschops,oper)>

	</cfif>
  </cfif>
</cfif>
</cfif>

<cfif isdefined("left_gonad_length") and len(left_gonad_length) gt 0>
  <cfset mapurl = "#mapurl#&left_gonad_length=#left_gonad_length#">
  <cfif compare(left_gonad_length,"NULL") is 0>
      <cfset basQual = " #basQual# AND ConcatAttributeValue(flat.collection_object_id,"left_gonad_length") is null">
  <cfelse>
    <cfset basJoin = " #basJoin# INNER JOIN v_attributes tbl_left_gonad_length ON (#session.flatTableName#.collection_object_id = tbl_left_gonad_length.collection_object_id)">
    <cfset basQual = " #basQual# AND tbl_left_gonad_length.attribute_type = 'left gonad length'">
    <cfif session.flatTableName is not "flat"><cfset basQual = " #basQual# AND tbl_left_gonad_length.is_encumbered = 0"></cfif>
    <cfif left_gonad_length neq "_">
    <cfset schunits="">
    <cfset oper=left(left_gonad_length,1)>
    <cfif listfind(numattrschops,oper)>
