Hi!
Sorry, forget that _Screen.Forms collection already updated by that form in the form Load method. The condition should be following:
if _Screen.Forms(i).Name == this.Name AND _Screen.Forms(i)<>this
Note that object references are compared correctly in VFP.
HTH.
>Vlad,
>
>I am very confused. If you saw my other reply to you, you know my problem is that I just get a flash of the form when your suggested code is in the LOAD event of the Class OR the Form. I think the problem is in the third line of code that says
>
>
> if _Screen.Forms(i).Name == this.Name
>
>
>This line returns a True condition even though this is the first instance of the form. Looking in the _Screen.Forms() Collection in Debugger just before the first line of LOAD event fires, I can see that the form exists with the same name as the one I am creating.
>
>What's the deal? I don't understand.
>
>>Hi!
>>
>>First of all, do not use the variable created with name that match to form name. This variable is usable only in design-time mode for debugging purposes to quickly view the properties and objects of the form. In run-time mode this variable is nto reliable for referencing forms, do not use it in the code in the future.
>>
>>You can use the _Screen.Forms collection to check if some particular form is opened:
>>
>>* form class load event
>>if this.lOnlyOneInstanse
>> for i=1 to _Screen.FormCount
>> if _Screen.Forms(i).Name == this.Name
>> nodefault
>> _Screen.Forms(i).Show()
>> return .F.
>> endif
>> endfor
>>endif
>>
>>
>>HTH.
>>
>>>I know there has to be a standard way to do this. Within my app I launch forms from menus, from command buttons within other forms, and by double-clicking areas of forms, all using the DO FORM command. I am using the following code in the LOAD event of some of my forms to prevent creating a new instance of the form if it already exists:
>>>
>>>IF TYPE("Reportselect") = "O" and !ISNULL(Reportselect)
>>> Reportselect.Show()
>>> RETURN .F.
>>>ENDIF
>>>
>>>Of course "Reportselect" is the name of this particular form. How can I use a generic version of this code in the base class for my forms.
>>>
>>>
>>>Thank you kindly for your help.
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.comICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs
It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.