Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Form is not an object" - error in executable but not project.

Status
Not open for further replies.

Kbutt

Programmer
Sep 10, 2001
3
CA
I use the following code within a procedure on my menu and it works find when runing within the project. When I compile an executable and choose the menu option, I get the following error: "Form is not an object".

FOR x = 1 TO _screen.FormCount
if _screen.forms(x).name = alltrim(m.shttype)
_screen.forms(x).release
endif
ENDFOR

I used the following as a work around, but am interested in knowing why the above gives an error in an executable only.

DO FORM dirforms + "orders.scx"
_screen.forms(2).release

Thanking you in advance for your help.
 
Because the Forms collection is dynamically renumbered when you release forms, you can skip forms and/or try to access forms that no longer exist. Change your loop to:
Code:
FOR x = _screen.FormCount to 1 Step -1
   if _screen.forms(x).name = alltrim(m.shttype)
      _screen.forms(x).release
   endif
ENDFOR
Rick

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top