Results 1 to 2 of 2

Thread: how to stop controls updating database immediately on lost focus?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    81

    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?

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    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:
    1. Private Sub datPrimaryRS_WillChangeRecord(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
    2.   'This is where you put validation code
    3.   'This event gets called when the following actions occur
    4.   Dim bCancel As Boolean
    5.  
    6.   Select Case adReason
    7.   Case adRsnAddNew
    8.   Case adRsnClose
    9.   Case adRsnDelete
    10.   Case adRsnFirstChange
    11.   Case adRsnMove
    12.   Case adRsnRequery
    13.   Case adRsnResynch
    14.   Case adRsnUndoAddNew
    15.   Case adRsnUndoDelete
    16.   Case adRsnUndoUpdate
    17.   Case adRsnUpdate
    18.   End Select
    19.  
    20.   If bCancel Then adStatus = adStatusCancel
    21. End Sub
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width