oasisp
Posts: 48
|
Posted: 02/21/2017, 3:54 PM |
|
i have some custom code to check duplicate on insert on BeforeInsert I have following
$additems->InsertAllowed = false;
but when I try insert it won't show Button_Insert after I submit.
how can I seee Button_Insert all the time to try another insert.
I have tried following but still not displaying
$additems->Button_Insert->Visible = True;
$additems->Button_Insert->Show();
|
|
|
MichaelMcDonald
Posts: 640
|
Posted: 02/22/2017, 4:59 AM |
|
can you place the duplicate checking in the on validate event and not worry about hiding the button ?
I say this as I suspect the button would need to be hidden in the forms beforeshow event...
_________________
Central Coast, NSW, Australia.
|
|
|
eratech
Posts: 513
|
Posted: 02/22/2017, 5:53 PM |
|
@oasisp - agree with Michael - put that into the OnValidate of the form.
You don't need to force the InsertAllowed = false as that will hide the button (as you found)
If you are validating you can either add an Error to the form (which will stop the insert and return to the form, with error message):
if ($Form1->TextBox1->GetValue() < 10 or $Form1->TextBox1->GetValue() > 50) {
$Form1->Errors->addError("The value must be greater than 10 and smaller than 50");
}
or you can return 'false' from the BeforeInsert function which will usually not carry on the Insert
or you can use the 'DataSource->CmdExecution' flag (see the DataSource properties of the Record). I think this the sort of thing you were trying to do, as it will directly stop the Insert/Update/Delete, without affecting the overall form. It is particularly useful with Editable Grid where you want to process many items, and fail a few instead of failing the entire grid.
Cheers
Eric
I
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia |
|
|
|