       <cfset basQual = " #basQual# AND tbl_head_length.attribute_value #oper# '#schTerm#'">
     </cfif>
   </cfif>
+</cfif>
 </cfif>
 
 <cfif isdefined("head_width") and len(head_width) gt 0>
   <cfset mapurl = "#mapurl#&head_width=#head_width#">
-  <cfset basJoin = " #basJoin# INNER JOIN v_attributes tbl_head_width ON (#session.flatTableName#.collection_object_id = tbl_head_width.collection_object_id)">
-  <cfset basQual = " #basQual# AND tbl_head_width.attribute_type = 'head width'">
-  <cfif session.flatTableName is not "flat"><cfset basQual = " #basQual# AND tbl_head_width.is_encumbered = 0"></cfif>
-  <cfif head_width neq "_">
+  <cfif compare(head_width,"NULL") is 0>
+      <cfset basQual = " #basQual# AND ConcatAttributeValue(flat.collection_object_id,"head_width") is null">
+  <cfelse>
+    <cfset basJoin = " #basJoin# INNER JOIN v_attributes tbl_head_width ON (#session.flatTableName#.collection_object_id = tbl_head_width.collection_object_id)">
+    <cfset basQual = " #basQual# AND tbl_head_width.attribute_type = 'head width'">
+    <cfif session.flatTableName is not "flat"><cfset basQual = " #basQual# AND tbl_head_width.is_encumbered = 0"></cfif>
+    <cfif head_width neq "_">
     <cfset schunits="">
     <cfset oper=left(head_width,1)>
     <cfif listfind(numattrschops,oper)>

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

<cfif isdefined("dimensions") and len(dimensions) gt 0>
  <cfset mapurl = "#mapurl#&dimensions=#dimensions#">
  <cfset basJoin = " #basJoin# INNER JOIN v_attributes tbl_dimensions ON (#session.flatTableName#.collection_object_id = tbl_dimensions.collection_object_id)">
  <cfset basQual = " #basQual# AND tbl_dimensions.attribute_type = 'dimensions'">
  <cfif session.flatTableName is not "flat"><cfset basQual = " #basQual# AND tbl_dimensions.is_encumbered = 0"></cfif>
  <cfif dimensions neq "_">
    <cfset oper=left(dimensions,1)>
    <cfif listfind(charattrschops,oper)>
      <cfset schTerm=ucase(right(dimensions,len(dimensions)-1))>
    <cfelse>
      <cfset oper="like"><cfset schTerm=ucase(dimensions)>
    </cfif>
    <cfif oper is "!"><cfset oper="!="></cfif>
    <cfif oper is "like">
      <cfset basQual = " #basQual# AND upper(tbl_dimensions.attribute_value) #oper# '%#ucase(escapeQuotes(schTerm))#%'">
	<cfelse>
      <cfset basQual = " #basQual# AND upper(tbl_dimensions.attribute_value) #oper# '#ucase(escapeQuotes(schTerm))#'">
	</cfif>
  </cfif>
</cfif>

<cfif isdefined("diploid_number") and len(diploid_number) gt 0>
  <cfset mapurl = "#mapurl#&diploid_number=#diploid_number#">
  <cfset basJoin = " #basJoin# INNER JOIN v_attributes tbl_diploid_number ON (#session.flatTableName#.collection_object_id = tbl_diploid_number.collection_object_id)">
  <cfset basQual = " #basQual# AND tbl_diploid_number.attribute_type = 'diploid number'">
  <cfif session.flatTableName is not "flat"><cfset basQual = " #basQual# AND tbl_diploid_number.is_encumbered = 0"></cfif>
  <cfif diploid_number neq "_">
    <cfset oper=left(diploid_number,1)>
    <cfif listfind(charattrschops,oper)>
      <cfset schTerm=ucase(right(diploid_number,len(diploid_number)-1))>

      <cfset basQual = " #basQual# AND upper(tbl_diploid_number.attribute_value) #oper# '#ucase(escapeQuotes(schTerm))#'">
	</cfif>
  </cfif>
</cfif>
</cfif>

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