Refreshing form based on changed values in master form

I have a single row form (form1) with a few fields on it and a editable grid view form (form2). I would like to have form2 refresh using the changed values from form1.field1 and form1.field2. I am able to get form2 to refresh using form2.src = form2.scr in the onChange event for the fields, but it continues to use the original values of field1 and field2. I have found a couple of session variables that I can set that cause a new record in form2 to default to the new values from field1 and field2, but I have not figured out how to change the sql where statement for form2 refresh. Any ideas? (If form1 needs to be grid or control, I can switch to that. I just don’t want to make the user click a button to refresh the data.)

Re: Refreshing form based on changed values in master form

Please check the sc_macros, I remember there was specially a macro for this job …

Just checked the manual, think sc_master_value is what you need

Re: Refreshing form based on changed values in master form

I believe that goes the wrong way. That will change a value on master form in a detail form event. I want to go the other way master form event change a detail variable.

Re: Refreshing form based on changed values in master form

Finally figured this out. Learned a lot. Here is what I finally ended up doing.

Created an ajax onChange event for each field on form1 necessary and in thoset events, I have the following code:
$_SESSION[‘sc_session’][$this->Ini->sc_page][‘form2’][‘foreign_key’][‘fieldx’] = {field1}; //change this for each field and foreign key in form2 as necessary – this causes the new record on form2 to default to the value from form1.field1

$_SESSION[‘sc_session’][$this->Ini->sc_page][‘form2’][‘where_filter’] = “fieldx = '” . {field1}. “’ AND fieldy = '” . {field2} . “’”; //change this to meet your where filter as necessary

$javascript_function = ‘refreshdet’; // Javascript function name
$javascript_parameters = array( ); //javascript parameters – don’t have any
sc_ajax_javascript($javascript_function, $javascript_parameters); //this calls javascript in ajax events

Created javascript function refreshdet and have the following in it:
var elem = document.getElementById(‘nmsc_iframe_liga_form2’); //grab the detail form
elem.src = elem.src; //cause the form to reload

Hope this helps others.