Form field read only on value from other table

Hi There,

i have a form with a select field in it (field name is wk_conf_container) . if a record is avaliable in a table i want this field to be set as read only. so i put this code in the onloadrecord (form is in editable grid)

i// concept alleen lezen indien er deelnemers zijn

// SQL statement parameters
$check_table = ‘ILP_rooster_deelnemer’; // Table name
$check_where = “wk_id = {wk_id} AND ev_id = [ev_id]”; // Where clause

// Check for record
$check_sql = ‘SELECT *’
. ’ FROM ’ . $check_table
. ’ WHERE ’ . $check_where;
sc_select(dataset, $check_sql);

if (false == {dataset})
{
// Error while accessing database
}
elseif ({dataset}->EOF)
{
// No record found
sc_field_readonly({wk_conf_container}, ‘off’);
}
else
{
// Record found
sc_field_readonly({wk_conf_container}, ‘on’);
}

the problem is that all the records field wk_conf_container are now or read only or selectable…?

strange or do i do something wrong?

also doesn’t work…

// Aantal aanmeldingen per workshop

$param = {wk_id};

$sql_command = “SELECT
count(*) AS COUNT_0 FROM ILP_rooster_deelnemer WHERE wk_id =”.$param."";
sc_lookup(ds,$sql_command);

{aantal_a} = {ds[0][0]};

{aantal_deelnemers} = “{aantal_a} / {wk_max_d}”;

if ({aantal_a} != 0) // Set as read-only
{
sc_field_readonly({wk_conf_container}, ‘on’);
}
else // Set as editable
{
sc_field_readonly({wk_conf_container}, ‘off’);
}