Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What is wrong with the following code?
Message
From
24/09/1998 02:53:54
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
23/09/1998 18:53:04
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00140095
Message ID:
00140240
Views:
21
>Hi,
> In the click event procedure of a command button, Iam trying to launch a modal form (custfind.scx) and see couple of properties of custfind object once the launched form is closed.
>
>Right after the "do form.." line, Iam getting an error saying "dlgFind" is not object.
>
>What am I doing wrong?
>
>Iam giving below the code.
>
>Thanks
>Puri
>
>======The code==================
>local dlgFind
>do form findcust.scx name dlgFind linked ;
> with thisform.txtCustomer.Value
>if m.dlgFind.m_nCustId <> -1
> ? "The customer id is " + Str(dlgFind.m_nCustId)
> ? "The customer name is "+m.dlgFind.m_sCustName
> thisform.txtCustomer.Value = m.dlgFind.m_sCustName
>endif
>
>=============================
Puri,
Unlike modeless forms, when a modal form is called code is suspended till control returns from modal form. A modal form can return values in their unload event. So the generic modal form call is like :
do form mymodal with params to param

While this seem to be good, with a return value isn't enough in practice. Instead pass the caller reference to called form or initialize caller with a name clause. In both cases, instead of returning values, called form's any PEM would be able to play with caller's anyPEM. Now implementing these two approaches to your code :
* Caller was launched with a name clause
do form myForm name "frmCaller" linked

* Some code somewhere
local dlgFind
do form findcust.scx name dlgFind linked
*     with thithisform.txtCustomer.Value

* Modal form releasing - ie: a button click
if thisform.m_nCustId <> -1
 ? "The customer id is " + Str(thisform.m_nCustId)
 ? "The customer name is "+thisform.m_sCustName
 frmCaller.txtCustomer.Value = thisform.m_sCustName
 * and refresh the caller
 frmCaller.refresh
endif
Passing form ref is nearly the same :
local dlgFind
do form findcust.scx name dlgFind linked with thisform

* Modal form init
lparameters oCaller
this.oCaller = oCaller && Save it to a custom form prop

* Modal form releasing - ie: a button click
if thisform.m_nCustId <> -1
 ? "The customer id is " + Str(thisform.m_nCustId)
 ? "The customer name is "+thisform.m_sCustName
 thisform.oCaller.txtCustomer.Value = thisform.m_sCustName
 * and refresh the caller
 thisform.oCaller.refresh
endif
Still many other ways but this two are effective enough and very similar to logic of toolbars.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform