Calling forms (OpenInsight Specific)
At 24 MAY 1999 08:58:19AM Bob Silverstein wrote:
I would like to call a second form from a first. Specifically, the first form is "CUSTOMERS" and has the table "CUSTOMERS" associated with it. This form contains a record id and an editfield called "ZIPCODE". How can I program "ZIPCODE" to open a second form called "ZIP" associated with a second table called "ZIP" and use the value of "ZIPCODE" from the "CUSTOMERS" form as the record id in "ZIP"?
At 24 MAY 1999 01:52PM Greg James, ISIS, Inc. wrote:
Try using the OPTIONS event for the ZIPCODE field. You could write a script that gets the contents (text property) of the the ZIPCODE field and, if there is a zip code there, start your ZIP form. You could use START_WINDOW to start the new form. Pass the ZIPCODE field text value in CreateParam, e.g.:
Start_Window("ZIP",@Window,CreateParam)
Then, in the CREATE event of the ZIP form, set the key field to the value contained in CreateParam and use SEND_EVENT to send the READ event to the form.
At 25 MAY 1999 10:56PM Bob Silverstein wrote:
I can open the second window but cannot pass the record id to it. Can you clarify "CreateParam"?
Thanks.
At 26 MAY 1999 11:29AM Greg James, ISIS, Inc. wrote:
Let's say that in the 'ZIPCODE' edit line on the 'CUSTOMERS' form you place the following script in the 'OPTIONS' event.
Declare Function Get_Property
Declare Subroutine Start_Window
RetVal=Get_Property(CtrlEntId,'TEXT')
/*
you can use either "CtrlEntId" or "@Window:'.ZIPCODE'" or "'CUSTOMERS.ZIPCODE'" as the control name.
*/
If Len(RetVal) Then
Start_Window('ZIP',@Window,RetVal)
End
The value contained in 'RetVal' is passed to the 'ZIP' form. You could then place a script in the 'CREATE' event of the 'ZIP' form.
If you look at the form's create event, the top line (the one that you cannot edit) contains the following:
Function CREATE(CtrlEntId,CtrlClassId,CreateParam)
CtrlEntId contains the name of the control firing the event. In this case it is the 'ZIP' form, so its value is ZIP.
CtrlClassId contains the name of the type of control firing the event. In this case it is a form (or rather a window), so its value is WINDOW.
CreateParam contains any value that was passed to the form. When we started the form, we passed it the value contained in 'RetVal'.
Lets say that on the 'ZIP' form you have an edit line called 'KEYFIELD' that contains a primary key. Try using this script in the 'ZIP' form's CREATE event:
Declare Subroutine Set_Property,Send_Event
If Len(CreateParam) Then
Set_Property('ZIP.KEYFIELD','TEXT',CreateParam)
Send_Event('ZIP','READ')
End
Return 1
I hope this helps. If you have any other questions, feel free to email me at gjames@isisicor.com.
Greg