how to stop controls updating database immediately on lost focus?
I use VB6 ADO (dataenvironment, commands object)
In my app to maintain data tables I use several control (textbox, datacombo, ect) with set
their datasource and datamember properties properly. On the same datatable maintain form there
are two commandbuttons "post" and "cancel". Id like to update database when the user click on
"post" button, and he could escape from his chages cliclking on "cancel".
My problem is that these controls immediately post its changes when the focus left them. (They
automatically update the phisical database record) so I cant implement my buttons
functionality.
Can anybody help me?
Re: how to stop controls updating database immediately on lost focus?
That is one of the main reasons why data binding is evil... There might be something in the event of the dataenvironment like the ff. which you could use to intercept changes to the database...
VB Code:
Private Sub datPrimaryRS_WillChangeRecord(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
'This is where you put validation code
'This event gets called when the following actions occur
Dim bCancel As Boolean
Select Case adReason
Case adRsnAddNew
Case adRsnClose
Case adRsnDelete
Case adRsnFirstChange
Case adRsnMove
Case adRsnRequery
Case adRsnResynch
Case adRsnUndoAddNew
Case adRsnUndoDelete
Case adRsnUndoUpdate
Case adRsnUpdate
End Select
If bCancel Then adStatus = adStatusCancel
End Sub