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

Activeform is not an object

Status
Not open for further replies.
All of a sudden my menu has stopped working. Whenever there is a VFP report form open (opened using "REPORT FORM &lcRptFileName NOCONSOLE PREVIEW" for viewing and/or editing within my application any attempt to click on a menu selection results in the "Activeform is not an object" error. This error only occurs when a VFP report form is the frontmost window. The error message is repeated one time for each main menu item.

Does anybody have any suggestions as to what may be causing the problem and how it can be fixed?

The application was developed over the last 10 years using VFP6 and VPM6. It is way to massive an effort to try and port it to a more recent version of VFP.

Rick
 
This error is exactly what the message says.

Somewhere in your code, you have a reference to _SCREEN.ActiveForm. As the name suggests, that's a reference to the form (window) that is currently active. The report preview window does not count as an active form, and there is presumably no other form active. Hence the message.

I suggest you find the references to _SCREEN.ActiveForm. Presumably, there is one for each of the menu options (possibly in the SKIP FOR clause). Ideally, you should then find an alternative way of achieving whatever that bit of the code is supposed to do. If you can't do that, wrap the code in a test for _SCREEN.FormCount. If that evaluates to zero, it means there is no active form, so branch round the code in question.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
The error message is repeated one time for each main menu item.

This says it's likely in the SKIP FOR clause of those menu items.

Before you refer to _Screen.Activeform, it's a good idea to check that it's an actual object. In SKIP FOR clauses it can be tricky because unless you call a function it's a single expression. For that we have IIF():

IIF(Type("_Screen.Activeform")="0", ExistingExpression, .f.)

There isn't anything new going on. It's just that nobody noticed it until now. ;)
 
Mike & Dan,

You guys hit the nail on the head! Got me to remember that the application has an invisible form active all the time to check for an application shutdown by the System Administrator and there were "_Screen.ActiveForm" checks in various menu selections. I will come up with some better code now that I know exactly where the problem lies.

I can't thank you guys enuff!

Rick

PS 4 Mike: Some of the best times of my life were in Scotland. We lived in Thurso (way up in Caithness county) from 1972 through 1976. Our son was born there.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top