Cancel a DialogBox

I’ve been reading multiple posts regarding DialogBox and cancels but still cannot get mine to work.

In my PostOpen event in the main form, I want the use to select a date from a dialogbox based on another form. The date the user selects will be populated in the main form. That piece works. But when the user clicks Cancel, I get a “Type Mismatch” error.

*Here is where the DialogBox code begins in the PostOpen event in the main form:

Call workspace.DialogBox _

( "CalDateForm", True, True, False, False, _

False, False, "Select Date", tempdoc, True)



If Not Isnull(tempdoc.CalDate(0))  Then

	myDate = Cdat(tempdoc.CalDate(0))

	myDate2 = Format(myDate, "Short Date")

	

	Dim dateTime As NotesDateTime

	Set dateTime = session.CreateDateTime(myDate2)

	Call dateTime.AdjustDay( -1 )

	

	Dim dts As String

	dts = Format(Cstr(Cdat(dateTime.DateOnly)),"mm/dd/yyyy")

	doc.Date1 = dts

	

	doc.ReleaseDate = myDate2

	

End If

End Sub


In the form with the date dialogbox, “CalDateForm”, I have this code in the QueryClose:

Sub Queryclose(Source As NotesUIDocument, Continue As Variant)

If Source.DialogBoxCanceled Then

	Continue = True '** this needs to be true or the dialog box will never close even if the user presses cancel **

	Exit Sub '** exit sub added here **

End If

End Sub


When I click Cancel, the dialogbox disappears, but I receive a “Type Mismatch” message.

Any thoughts? Do I need to add some type of error checking code in the PostOpen event in the main form?

Subject: Cancel a DialogBox

use the debug mode and identify the line that gives the error message.

Subject: RE: Cancel a DialogBox

I’ve tried that but cannot use Debug when working with a DialogBox.

Subject: Cancel a DialogBox

try it like this instead:

enterdate:

cancelcheck% = workspace.DialogBox( “CalDateForm”, True, True, False, False, False, False, “Select Date”, tempdoc, True)

’ this captures the cancel event

If cancelcheck% = False Then

 MsgBox "you must select a date"

 goto enterdate

End If

Subject: RE: Cancel a DialogBox

Thank you it worked!!!