Passing a variable

I have searched the forums and I have found many solutions but none of which seem to be a solution to my problem. I am trying to pass one variable to a subform and “retain” the variable. It works fine actually, but once the code in the subform leaves the function I lose the variable. I’m setting the passing parameter to a global variable I have set in the subform. But as soon as I attempt to use the variable somewhere else in the subform, the variable is lost (null). To my understanding, the “var” field in CAL local parameters determines if the passing value is pass by reference or pass by value. I have tried ticking the var field field both ways and I’m still losing the variable. In a C++ function, this would normally work…am I attempting this the wrong way? I’m sure it’s just something stupid I’m doing wrong. [:D] Also, I would use David Singletons solution of passing thru a filter but I don’t have access to to modify the table I’m using. Thanks a lot!!

Could you provide some code? Normally, this should work just fine. Btw, the “var” option for local parameters should not make any difference here, unless you pass a record variable.

please forgive me for not understanding the situation much :)… may I ask if you are passing the variable from a parent form to a subform.

OK I’m passing the current “Item No.” to the subform on OnAfterGetCurrRecord. I cannot think of another way to pass the current item number to the subform, if you have a better way…please I’m all ears! [:)] here is a sample Main Form* IF (“Item No.” <> ‘’) THEN CurrForm.MySubform.FORM.getitemno(“Item No.”); Sub Form (Global Variable: ItemNo Type: Code[10]) getitemno(item : Code[10]) IF (item <> ‘’) THEN ItemNo := item; If I try to use ItemNo anywhere else in the subform the value is NULL. Althought its not passing a NULL value, it’s somehow loosing the value when I attempt to use it outside the function.

Hm, I tried this on the purchase order form/subform - no problem. I move to another PO, then click into the subform and activate the debugger. When I move around in the subform and the debugger gets activated, I check the global vars and voila! the value is there. There must be something else in your forms causing the problems… Exactly when are you trying to use the value? Are you sure the value is set before you are trying to access it?

I tried the same thing with the debugger and the value IS being set. I checked the global values and sure enough, the value passed in is now set to my global variable. I’m specifically trying to use the global value in the OnInsert trigger of the subform. Then when I “step into” with the debugger and I come to OnInsert the value of the my global variable is now NULL. It seems that the value only exists in the function and the fuction alone. There has to be something else I am missing. I really appreciate your help.[^]

Well, in my code the global variable keeps its value outside the setting function and across all sorts of subform triggers, just as it is supposed to. I will try inserting a new record and see what happens then. Hm, is there a chance for your globals getting reset on some occasion? You know, like a CLEAR on the subform or the like?

Erm… wait a sec… the OnInsert trigger is executed in the table, not in the form. How can you expect to use a variable defined in the form in this trigger???

SOLVED!!! I’m an idiot!![B)] What happened was the “subform” I was working with was on a Tab Control. I somehow drew TWO subform controls one on the RIGHT tab and the other one somehow/someway got stuck behind “ANOTHER” subform on “ANOTHER” Tab Control!! That tab control somehow got the subform name I was working with thus the control I was trying to pass the variable was working just fine, it was just going to the OTHER subfrom hidden behind another subform on another tab!! Confused yet?!? I deleted the hidden subform and renamed the RIGHT subform and viola, it works like a charm. Thanks for your help!

I’m using OnInsertRecord on the subform, sorry not OnInsert.

[:D][:D][:D] Now this is cool - a form with tabbed subforms! Completely eliminates the need for those pesky pop-up windows when displaying comments, ledger entries or invoice headers. Just don’t tell our users that this is possible [;)]