Run Sql statement as default input for a field

Hi all.

I have a field such as Customer Number. Everytime I add a new I want to have a count of all records availavle in database “select concat(‘Cust’, count(custid)+1) as field from customer)” then the results to be a default value for a new customer number.

When I set this sql query to default add page, the page doesn’t show.

Thanks in advance

You may use Row_Rendered server event (see Server Events and Client Scripts in the help file) to set your default value, e.g.

if ($this->isAdd()) $this->MyField->EditValue = ExecuteScalar(“SELECT …”);