DataGrid and BeforeUpdate
Posted on 2000-02-23
Hi guys... this is my problem.
In a form I have:
1) One Datagrid, linked to an AdoData control. this works ok.
3) All fields must be filled (IMPORTANT). This is a rule into the table (MDB).
4) A CommandButton.
5) A Sub (CancelAdd) for canceling row adds in the DataGrid.
How this works:
1) When I want to add a registry I press the "Add" CommandButton. This is Ok.
2) To cancel the add before or after filling some or all field I press ESC and the CancelAdd sub is called. This is ok.
3) The CancelAdd Sub do:
And locate the cursor in another cell. This is Ok too.
4) There is a button to cancel the adding too. When I press it, it calls the same CancelAdd sub, and gives me an error: "Blank fields are not allowed" (because of the table's rules).
The first method (ESC) is called from DataGrid_KeyUp, the second in Command1_Click.
The only one difference I've notice when I click on the button is that the DataGrid1_BeforeUpdate event is activated, but doing it with ESC the BeforeUpdate is not called.
If I Cancel the BeforeUpdate, It wont let me get out of the registry, and the cursor stays in the last row even allowupdate or allowaddnew are disable.
What the hell happens here?