cancel
Showing results for 
Search instead for 
Did you mean: 

How to close not visible form?

Former Member
0 Kudos

I have a "modal" form which is, at a point of time, made visible = false.

when i close my addon I would like to completely close it. but when i do form.close() I get exception about "invalid form".

any help how to solve this?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

Are you making sure you are referencing the correct form in the oForm variable? My guess is that you first have to load the form using ...

oForm = SBO_Application.Forms.Item(strUniqueID)
oForm.Select()

where strUniqueID is your form referenced by its unique id name.

hope it helps

Former Member
0 Kudos

yes i'm sure. form object is OK.. is not null .. is instantied etc. why would the select() be required ?

Former Member
0 Kudos

At which point are you trying to close the form? Are you doing it at the SBO_Application_AppEvent event handler ?

It may be that the form is already closed when you are trying to close it. How can you tell the form existence is still running in the system ?

Answers (1)

Answers (1)

former_member191896
Active Participant
0 Kudos

Hi Cristian,

You can put the call to Form.Close in try block and then ignore the exception when it is caught in the catch block. Or you can explicitly check if the form exists in the Forms collection before trying to close it.

HTH

Aravind

Former Member
0 Kudos

thanks. this is the temporary solution. but i still don;t understand why I get the error although the form exists in forms collection in Application object...

Former Member
0 Kudos

after more insight with Dragos Creutu member of the forum on the problem, we found out tha the form was already closed. it was very confusing because even was closed, the object was "ok" : instantiated, had members etc... weird