 	<cfoutput>
 		<cfset title = "Search for specimens or encumbrances">
 		<p>
-			<cfif len(table_name) gt 0>
+			<cfif len(table_name) gt 0 or len(collection_object_id) gt 0>
 				Now find an encumbrance to apply to or remove from the specimens below. If you need a new encumbrance, create it
 				first then come back here.
 			<cfelse>

				WHERE
					flat.collection_object_id=coll_object_encumbrance.collection_object_id (+) AND
					coll_object_encumbrance.encumbrance_id = encumbrance.encumbrance_id (+) AND
					flat.collection_object_id IN (
						select collection_object_id from #table_name#
					)
				ORDER BY
					flat.collection_object_id
			</cfquery>


			<cfdump var=#getdata#>


		<hr>

	<cfif len(encumbrance_id) is 0>
		Didn't get an encumbrance_id!!<cfabort>
	</cfif>
	<cfif  len(table_name) is 0 AND LEN(collection_object_id) IS 0>
		Didn't get specimens<cfabort>
	</cfif>
	<CFIF LEN(table_name) GT 0>
		<cfquery name="unencumberedSpecimens" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
				INSERT INTO coll_object_encumbrance (
					encumbrance_id,
					collection_object_id
				) (
					select
						#encumbrance_id#,
						collection_object_id
					from
						#table_name#
					where
						collection_object_id not in (
							select
								collection_object_id
							from
								coll_object_encumbrance
							where
								encumbrance_id=#encumbrance_id#
						)
			)
		</cfquery>
	<CFELSEIF LEN(collection_object_id) GT 0>
		<CFTRANSACTION>
			<CFLOOP LIST="#collection_object_id#" INDEX="I">
				<cfquery name="unencumberedSpecimens" datasource="user_login" username="#session.dbuser#" password="#decrypt(session.epw,session.sessionKey)#">
					INSERT INTO coll_object_encumbrance (
						encumbrance_id,
						collection_object_id
					) values (
							#encumbrance_id#,
							#i#
						)
				</cfquery>

			</CFLOOP>
		</CFTRANSACTION>
	</CFIF>

	<p>
		All items listed below have been encumbered.
