How to pass parameters to Form

I need to pass parameters to form when I open it from another form. Can you give me an idea how to make it? Thanx!

The easiest way is to set up a Function in the Form you want to call, with your chosen parameters. If you assign these to Globals in the Function, you can run the form from the source code straight afterwards and the values will still be there. Hope that helps.

Make a function on form2 : PassVariable(var1,var2); Make a variable on form1 : Form2. Call the function Form2.PassVariable(var1,var2);

I tried this but it doesn’t work!! Where could be problem ?

I use this way to make forms editable or not editable, depending on from where you open the form. // My button to open the form OnPush() CLEAR(OrderStatusForm); OrderStatusForm.SetEditable(TRUE); OrderStatusForm.RUN // My form OnOpenForm() CurrForm.EDITABLE(EditableForm); SetEditable(NewEditableForm : Boolean) EditableForm := NewEditableForm;

In this case you even don’t need to do so. You can write like this: OnPush() CLEAR(OrderStatusForm); OrderStatusForm.EDITABLE(FALSE); OrderStatusForm.RUN

I tried to do with that function. I run the process with debugger and saw that OnOpen form clears those global variables. Maybe it’s because i have SaveValues property set to TRUE ? I’m working with Attain 3.01!

Hi Perhaps it is better to work with a rec and a form variable if you want to set a filter on your second form. something like this: YourRec.SetRange(YourField1,YourFilter1); YourRec.SetRange(YourField2,YourFilter2); YourForm.SetTableView(YourRec); YourForm.Run; bye André

Yes, that works if I want to set filter, but not to pass some parameters. I’ve solved this problem in different way but anyway it’s interesting why I couldn’t pass using function [?]

quote:


OnOpenForm() CurrForm.EDITABLE(EditableForm); SetEditable(NewEditableForm : Boolean) EditableForm := NewEditableForm;


quote:


I tried to do with that function. I run the process with debugger and saw that OnOpen form clears those global variables. Maybe it’s because i have SaveValues property set to TRUE ?


My code works for me. I tried it again with different values on the SaveValue property. I find it very useful to insert this code in all forms that contains codes that are connected to orders, items, customers etc. If you put this code in the Salespeople/Purchasers form, all fields that will open this form through a tablerelation will open not editable. You can then decide from where you want to open the form in editable mode. Probably from the setup.

Hi Athur I played a little with forms and passing variables (3.01B). It works. Form1 Variables Name DataType Subtype Length frm2 Form form2 x Integer On form1 is a button with the OnPush - action: x:= 5; frm2.getx(x); frm2.RUN; Form2 Variables Name DataType Subtype Length y Integer Functions getx Locals: Var Name DataType Subtype Length Ja x Integer Code form2 getx(VAR x : Integer) y:=x; On form2 is a Textbox with SourceExp : y. If I push the button on form1 form2 appears with a value 5 in the textbox. bye André