Urgent! Form Closes when previewing the form - is it my code?

Hi all,

Everytime i try to preview one of my forms, it appears to close immeadiately and I dont know why. This has not happened before.

Also when I made a copy of the database, I have noticed that the same form opens fine on the second copy. However when copying the same form over onto my current database, the page still closes when previewing it. I really need some help on this asap.

I think it may have something to do with my code?

REM Declaring the variables for the Lotusscript PostOpen Object

Sub Postopen(Source As Notesuidocument)

If source.IsNewDoc Then

	Dim ws As New notesuiworkspace

	Dim s As New notessession

	Dim db As notesdatabase

	Set db = s.Currentdatabase

	Dim assetdb As NotesDatabase

	Set assetdb = OpenDbfromconfig("cd_ReplicaIDLsContact", "Asset Tracking","DOMAPPS3/Comp")

	REM Accessing the view to collect the data from the view

	Dim view As NotesView

	

	REM Creating a diloague prompt box to prompt the end user to make a selection with regards to choosing monthly, weekly and acceptance checklists.

	REM Data is then displayed based on the selection made by the end users selection.

	Dim optionslist As Variant

	optionslist = Evaluate(|@Unique(@DbColumn("Notes":"Nocache";@getprofilefield("fa_cd";"cd_ReplicaIDFlContact");"va_vusbit";1))|)

	checklistval= ws.Prompt(4,"Create Checklist For Data Centre", "Please select the data centre you wish to create a checklist for","",optionslist)

	If checklistval = "" Then

		source.Close

		Exit Sub

	End If

	Call source.FieldSetText("Checklistname",checklistval)

	

	Dim fieldnamearray(0 To 4, 0 To 1)

	'*********************************************************************************************

	'BACKUP SERVER DOCS

	Set view = assetdb.GetView("va_vusbit")

	Dim documentcollection As NotesDocumentCollection

	Set documentcollection = view.GetAllDocumentsByKey(checklistval,True)

	Dim tasktemplatedoc As notesdocument

	Set tasktemplatedoc = documentcollection.GetFirstDocument

	REM Accessing information within an array and saving the details.

	REM If nothing is selected, this therefore means no data can be displayed.

	While Not(tasktemplatedoc Is Nothing)

		'Create backup task document

		Dim newtaskdoc As New notesdocument(db)

		With newtaskdoc

			.form = "fa_st"

			.servername = tasktemplatedoc.name(0)

			.checklistunid = source.Document.UniversalID

			.status = "Not Complete"

			.assignedto = s.UserNameList(0).abbreviated

		End With

		Call newtaskdoc.makeresponse(source.Document)

		Call newtaskdoc.Save(True,True,False)

		'Create disk space  document

		Dim newdstaskdoc As New notesdocument(db)

		With newdstaskdoc

Thank you in advance

Subject: Urgent! Form Closes when previewing the form - is it my code??

Hi Gem -

Turn on LotusScript debug then preview the form. When postopen fires off, step through it. Which line is puking?

I suspect that your optionlist is not returning a value and thus there is nothing to prompt the user with. You programmed the form to close in this case:

If checklistval = “” Then

source.Close

Exit Sub

See what I mean? It is doing what you told it to do. Fix the lookups and you should be fine.

HTH,

Trish