Script Problem - Trying To Exit From A Loop

Hi

Can anyone help me please?

When I prompt for a start date from the input box & user selects cancel, I want it to not loop back in.

Same problem occurs with the end date prompt.

Hope someone can help?.

Thanks

Sub Click(Source As Button)

Dim ws As New notesuiworkspace

Dim session As New NotesSession

Dim db As NotesDatabase

Set db = session.CurrentDatabase

Dim doc As NotesDocument

Dim view As NotesView

Dim vc As NotesViewEntryCollection

Dim coll As notesdocumentcollection

Dim ndt As New NotesDateTime("01/01/1900")





Set view = db.GetView("LocSearch")

Set vc = view.AllEntries

If vc.count > 0 Then

	response = Messagebox("Starting a new search will remove the results from the previous search."+Chr(10)+_

	"Do you wish to continue?",36,"Location Search")

	If response = 6 Then 'Yes

		Print "Marriages Location Search - Removing previous search results..."

		Call vc.RemoveAllFromFolder( "LocSearch" )

	End If

	

	If response = 7 Then 'No

		

		Continue = False

		

	End If

End If

’ Set view = db.GetView(“DO”)

'

no1:

response = Inputbox("Please enter the start date of your search. Please enter the format of DD/MM/YYYY","Location Search")

’ response2 = Cdat(Format(response,“dd/mm/yyyy”))

If Not (response Like "##/##/####") Then

	Msgbox "Date must be in the format of DD/MM/YYYY",16,"Stop"	

	Goto no1

End If



'If response = 2 Then 'No

'	Continue = False

'End If

no2:

endresponse = Inputbox ("Please enter the end date of your search. Please enter the format of DD/MM/YYYY", "Location Search")

'endresponse2 = Cdat(Format(endresponse,“dd/mm/yyyy”))

If Not (endresponse Like "##/##/####") Then

	Msgbox "Date must be in the format of DD/MM/YYYY",16,"Stop"	

	Goto no2

End If





xForm = | Form = "regform" & dateopened >=@TextToTime("| & (response) & |") & dateopened <= @TextToTime ("| &( endresponse )& |") & dateopened!= ""|  



'Confirmation of archive

areyousure = Messagebox("Are you sure you wish to search between the dates of " + Cstr(response) + " to " + Cstr(endresponse), 36, "Location Search")



If areyousure = 7 Then 'No

	Messagebox "Searching for monthly figures report cancelled.", 64, "Location Search"

	Exit Sub

End If

'Get All documents with that year

Print "Please wait while the system finds all of the cases..."



Set coll=db.Search(xForm,ndt,0)





If coll.count = 0 Then ' amended to coll TB

	Messagebox "The system has found no cases matching dates between"+ Cstr(response) + " and " + Cstr(endresponse), 64, "Location Search"

	Exit Sub

End If



		'Copy to folder

Call coll.PutAllInFolder( "LocSearch" )  ' amended to coll TB







Print "Searching complete - please wait while the view is refreshed ... (this can take upto 30 minutes)"

'Refresh view at end (This can take a while if a large number of documents have been moved)

Call ws.viewrefresh

Print "Searching complete - thank you for waiting"

If coll.count > 0 Then

	Messagebox "The system found "+ Cstr(coll.count) +" cases ""."+_

	Chr(10)+" .",64,"Location Search"

	

End If	

End Sub

Subject: From the help…

UsageInputBox displays a dialog box with OK and Cancel buttons and a text entry field, interrupting execution of the script until the user confirms the text entry by clicking OK or Cancel. Then InputBox returns that entry. If the user clicks Cancel, InputBox returns the empty string (“”). When the user clicks OK or Cancel, execution resumes.

Therefore test:

If response = “” Then Exit Sub

Also, your first test should be like this (setting Continue = False does nothing)…

response = Messagebox(“Starting a new search will remove the results from the previous search.”+Chr(10)+_

	"Do you wish to continue?",36,"Location Search")

If response = 7 Then Exit Sub 'No

'Yes

Print “Marriages Location Search - Removing previous search results…”

Call vc.RemoveAllFromFolder( “LocSearch” )

Subject: RE: From the help…

Bill

Works a treat.

Many Thanks

Mick