The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
How to close a Form
Posted: 30 Nov 07 8:26 PM
|
I have a button on a form named btnCancel, and this script is bound to the onClick event But it does not work , wont close the form. what is up?
Sub CancelClick(Sender) '' close current form Application.BasicFunctions.CloseCurrentView(false) End Sub
Thanks Alan Young
|
|
|
|
Re: How to close a Form
Posted: 01 Dec 07 12:06 AM
|
Today must be the day !
This is a legacy function and should no longer be used, especially when invoking a view as a MainView.
Use frmName.Close
|
|
|
|
Re: How to close a Form
Posted: 03 Dec 07 1:22 PM
|
ok i tried
Contact:MyForm.Close Contact:MyForm.Close() Me.Close Me.Close()
all are not working. I get variable is undefined
What am I missing?
|
|
|
| |
|
Re: How to close a Form
Posted: 03 Dec 07 2:19 PM
|
Ok after much experimentation I came up with the following that works.
Assuming the form.name property is "ContactForm123" then I can call a sub I made named CloseMyForm That sub goes through the application.forms object and finds my form. Then it sets modal result= mrCancel.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Sub CancelClick(Sender)
CloseMyForm("ContactForm123")
End Sub ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Sub CloseMyForm(formName) dim thisviewname dim thisviewid dim strthisform
dim i dim mvcount dim myformindex dim myFormCaption dim MyFormName
myFormName=formName mvcount=application.Forms.Count myformindex=-1 for i = 1 to mvcount -1 thisviewname=Application.Forms.Item(i).Name if trim(thisviewname)=myFormName then myformindex=i ' msgbox "found my form at " & myformindex & " " & myformname end if next
if myformindex > -1 then 'msgbox "Closing form " & myFormName & " at " & myformindex Application.Forms.Item(myformindex).ModalResult=mrCancel '''' by the way this does NOT WORK '''' Application.Forms.Item(myformindex).Close end if
end Sub
|
|
|
|
Re: How to close a Form
Posted: 01 Jul 08 3:48 PM
|
It is easier to set frmMyForm.ModalResult to anything but mrNone. For example [code] frmMyForm.ModalResult = mrCancel[/code] |
|
|
|