What is wrong with this line of code?

Please check the code below, i’m having problem with the notesdocumentcollection. i have 2 DBs: DB2 serves as a lookup database for DB1. The lookup was working properly till i revised something on DB2. The weird thing was in prod the code is not working but in dev it has no problem at all…any ideas is highly appreciated…pls. need help on this.

Also, i am not sure if the problem in prod has something to do with the version…we used notes 7 to replace the design of the 2nd database while the code was originally done in notes 6

Sub GetFldVals

If uidocSource.IsNewDoc Then

	

	docSource.FinalNatureOfIncident = uidocSource.FieldGetText( "NatureOfIncident" )

	docSource.OtherFinalNature = uidocSource.FieldGetText("OtherNature")

	

End If



strIRStatus = uidocSource.FieldGetText( "IRStatus" )

If strIRStatus <> "Cancelled" And strIRStatus <> "Closed" And strIRStatus <> "Resolved" Then

	

	Dim currdb As Notesdatabase

	Dim dbAS As Notesdatabase          

	Dim sessIR As New Notessession

	Dim dbcollSys As Notesdocumentcollection

	Dim systemname As Variant

	Dim docProfile As NotesDocument

	

	Set currdb = sessIR.Currentdatabase

	Set docProfile = currdb.GetProfileDocument("frmProfile")

	Set dbAS = sessIR.Getdatabase( docProfile.AppSysServer(0), docProfile.AppSysFilename(0) )

	

	systemname = Evaluate(|@Middle("| & uidocSource.Fieldgettext( "AffectedSystem" ) & |";"> ";5000)|)

	If Trim(systemname(0)) = "" Then

		docSource.SystemName = uidocSource.Fieldgettext( "AffectedSystem" )

	Else

		docSource.SystemName = systemname(0)			

	End If

	

	Set dbcollSys = dbAS.Search( |Form = "frmSysName" & BankClass = "| & _

	uidocSource.Fieldgettext( "BankClass" ) & |" & SystemName = "| & _

	uidocSource.FieldgetText("SystemName") & |"| , Nothing, 0 ) 

	

	If dbcollSys.Count <> 0 Then               

		Set docSys = dbcollSys.GetFirstDocument()

		strNxtUsr = uidocSource.FieldGetText( "NxtUsr" )               

		If strNxtUsr <> "SectionHead" And strNxtUsr <> "DeptHead" Then

			docSource.AnalystInCharge = docSys.AnalystInCharge(0)

			docSource.BackupAnalyst = docSys.BackupAnalyst(0)

		End If

		If strNxtUsr <> "DeptHead" Then

			docSource.SectionHead = docSys.SectionHead(0)

		End If              

		docSource.Department = docSys.Department(0)

		docSource.SystemCode = docSys.SystemCode(0)

		If docSource.SystemCode(0) = "" Then

			docSource.SystemCode = "--"	

		End If

	End If          

%REM

THIS IS WHERE THE PROBLEM OCCUR (IN PROD) WHEN DBCOLLSYS.COUNT IS INVOKED, IT SEEMS THAT THE SEARCH IS NOT GETTING ANYTHING, BUT IT WORKS PERFECTLY WELL IN DEV

%END REM

			Set dbcollSys = dbAS.Search( |Form = "frmDept" &  Department = "| & docSource.Department(0) & |"| , Nothing, 0 )

	

	If dbcollSys.Count <> 0 Then

		Set docSys = dbcollSys.GetFirstDocument()   

					docSource.DeptHead = docSys.DeptHead(0)

	End If          

	

End If

End Sub

Subject: What is wrong with this line of code?

Do you get an error message?

If you don’t i.e. the collection is being returned but, with no entries, check your profile document in the production db to make sure the dbAS is being set to the correct db. If it is, try to search for the collection manually (through the notes search bar) in the db specified in the profile document.

Subject: RE: What is wrong with this line of code?

No, we don’t encounter any error message. and we are certain that the profile document is correct and the document that is supposed to be returned by the search exists.

the weird thing here is that we’ve tried to do the routine several times and we noticed that in some instances this code works. it returns the expected output.

and to make sure, we got a copy of the database in prod and have it tested in dev and it works good.

i really dont know what we are missing here… =(

Subject: RE: What is wrong with this line of code?

Did you try putting the search in manually as suggested?