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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check to see if object exists

Status
Not open for further replies.

KDavie

Programmer
Feb 10, 2004
441
US
I am trying to figure out a way to find if an object exists on a form. If it does I want it to remove it, otherwise I don't want it to do anything.

Here's my psuedo code:

If grdNotes exists then
ThisForm.RemoveObject("grdNotes")
Else
Endif

Any suggestions?

Thanks,

-Kevin
 
I figured out a way to accomplish my goal. I added a local variable name lcOldError, saved the current error handler, disabled error handling, removed the object, then restored the error handler back.

Here is my code:

lcOldError = ON("ERROR") && Save the error handler

ON ERROR * && Disable the current error handler
_Screen.ActiveForm.RemoveObject("grdNotes")
ON ERROR &lcOldError && Replace error handler

I'm not sure if this is a good practice or not, but it works.

-Kevin
 
Try pemstatus()

Darrell

i.e.
* In some form method:
[tt]
if pemstatus(this,"grdNotes",5)
this.removeobject("grdNotes")
endif
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top