I am going back and forth between 3-4 forms and I at times I get an error saying 'formName is not an object'. I am issuing Do form formName. Individual forms seem to work fine when I run them from the project manager. Any help appreciated.
Have you observed any pattern in the errors; like not happening the first time you start a given form, or only happening when you already have two forms open?
Are these forms you created in the form designer? Could you possibly have a variable you named the same as a form? What version and service pack of VFP do you have? Are all the forms added to your project?
If you are going back and forth between the forms, why not instantiate them and thereafter either minimize or use .Hide() in the .LostFocus events of the individual forms, if you don't want them to be visible.
In the code used to call a form put:-
IF VARTYPE(oForm2) = [O] && Forms exists
[tab].oForm2.Show() && or .oForm2.WindowState = 0
ELSE
[tab]DO FORM form2 NAME oForm2 LINKED
ENDI
When you release a form, put:-
RELEASE oForm2 && Release object reference
By having on object reference, it also gives you access to all the properties, events and methods of any form regardless of where you are.
Everytime I call a form I wrote the following code:
IF VARTYPE(oForm2) = [O] && Forms exists
oForm2.Show() && obj. ref. for the form
ELSE
DO FORM form2 NAME oForm2 LINKED
ENDIF
Everytime I close a form in the destroy event I wrote:
Release oForm2
Now when I click on my toolbar or the menu to load this form it the form window appears and then disappears. I can't see any data on the form but I can tell from the borders that it was the right form. I am not getting anymore "object not found errors".
I just took the linked keyword out and now I can view my forms. I get the object not found error when i try to select a value from a combo box on the form and try to use it in the sql statement. After giving the error the sql statement executes correctly. I don't get any errors when I run the forms indiviually.
and 3 other forms that are show in top level form.
when switching from one particular form to another particular form, I get the 'Object FormName is not found'
and the error occurs on a go top statement for a table in the Init event of the form I'm switching to. The error refers to the form I'm switching from.
I've used the same code as a template for one of my other projects and that project works fine.
Here is the SQL statement. I click on a command button on the form 'arcrpts' and then it calls the specified procedure in the program.Following is one of the erroneous SQL statement:
select * from clmlvl where (pkey in (select pkey from ipclm)) and alltrim(provider)=arcrpts.provnocbo.value into table clm2
I get this error everytime I refer to anything like arcrpts.*.*
It would appear you are using the form title arcrpts instead of the the object reference name of the form.
If the form arcrpts has the object reference name oArcrpts, the the code would be
select * from clmlvl where (pkey in (select pkey from ipclm)) and alltrim(provider)=oArcrpts.provnocbo.value into table clm2
Chris
I get the same error after I use the object refernce. I don't know why I need to use that because I am not Lilnking the object reference to the form name because if I do that than I cannot view my forms.
I was thinking about storing the value in a public variable and using that instead of arcrpts.provnocbo.value.
Everytime I call a form I wrote the following code: IF VARTYPE(oForm2) = [O] && Forms exists
[tab]oForm2.Show() && obj. ref. for the form
ELSE
[tab]DO FORM form2 NAME oForm2 LINKED
ENDIF Everytime I close a form in the destroy event I wrote:
Release oForm2
What should have been happening is that oForm2 should have replaced by the object reference for the particular form.
If you have literally used the code you posted in the various .Destroy events, then clearly there will have been a problem in implementing the use of an object reference.
If you consult the help file for DO FORM, you will find the following:-
If you omit the NAME clause, Visual FoxPro creates an object type variable with the same name as the form or form set file.
Your code:-
select * from clmlvl where (pkey in (select pkey from ipclm)) and alltrim(provider)=arcrpts.provnocbo.value into table clm2
would indicate that is what you are trying implement?
If you have literally used the code you posted in the various .Destroy events, then clearly there will have been a problem in implementing the use of an object reference
should be
If you have literally used the code you posted in the various events, then clearly there will have been a problem in implementing the use of an object reference
Now I am only using Do form formName
and in the destroy event I put:
Release formName.
Is this what you were trying to say.
I am still getting the same errors though.
I just took the linked keyword out and now I can view my forms.
I read that to mean that you were using the code
DO FORM form2 NAME oForm2 If you omit the NAME clause, Visual FoxPro creates an object type variable with the same name as the form or form set file.
The statement is correct but can be misleading, as your object reference arcrpts is out of scope in your SQL statement, hence the error.
As the use of LINKED appears to cause you a problem, try
DO FORM form2 NAME oForm2
and then
select * from clmlvl where (pkey in (select pkey from ipclm)) and alltrim(provider)=oForm2.provnocbo.value into table clm2
If it continues to go out of scope, declare oForm2 a PUBLIC variable before using it.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.