Weird CancelUpdate problem

Weird CancelUpdate problem

Post by Hofhacke » Thu, 20 Mar 2003 16:26:13

Hi all,

I'll try to explain what my problem is and hopefully someone can give me an


I have a couple of textfields which I've bound to an Access-DB like this:

txtSample1.DataSource = rs
Set txtSample1.DataField = "Sample1"
txtSample2.DataSource = rs
Set txtSample1.DataField = "Sample2"
txtSample3.DataSource = rs
Set txtSample1.DataField = "Sample3"
txtSample4.DataSource = rs
Set txtSample1.DataField = "Sample4"

I'm using an explicit Update / Cancel button, to make sure nothing changes

the Update button is pressed. The update works fine. But the cancel-button

works ok as long as you're only using the mouse or TabKey. But I have a
piece of

code which uses the EnterKey to set the focus on the next textfield:

Private Sub txtSample1_KeyPress(KeyAscii As Integer)
'Go to the following textfield
    If KeyAscii = vbKeyReturn Then
        KeyAscii = 0
    End If
End Sub

The problem is, when I'm using the EnterKey to go to the next textfields,

then decide to cancel the update, it only cancels the field where my cursor

in and he's updating the other fields (which isn't the case when using Tab

the mouse). The strange thing is, he hasn't updated the database until I

the Cancel-button, which invokes a 'recordset.CancelUpdate'. So the old

are still there, but using a cancelupdate, it makes the changed fields,

the cursor isn't in, do an update on the Database.
So, I can get the old values back by doing this before running the

'recordset.cancelupdate' command:

txtSample1 = rs.Fields("Sample1")
txtSample2 = rs.Fields("Sample2")
txtSample3 = rs.Fields("Sample3")
txtSample4 = rs.Fields("Sample4")

But I don't think it's a nice (and necessary) way to do... besides, if the

Database-Field is empty, it can give a problem saying 'Invalid use of Null'.

I was completely surprised and I haven't got a clue why he's doing this. I

really want to keep using the EnterKey, because it's much easier for my

Hope someone has an idea... Big thanks in advance!!!



1. CancelUpdate Problem


I am facing the CancelUpdate problem in VB6 for the controlls which get
input from another controlls (Not Keyboard) such as calendar or Datacombo.
If i use cancelUpdate the value are saved which i enterd.


2. Help!: Census/DBase snafu

3. CancelUpdate problem

4. design question...again

5. Problem: CancelUpdate FAILS for a DataGrid bound to Oracle database

6. sqlns.hlp

7. problems with Addnew and CancelUpdate

8. Updating nText column

9. problems with CancelUpdate and EditMode

10. CancelUpdate problems

11. CancelUpdate - problems???

12. CancelUpdate problems

13. Problem with dbgrid and CancelUpdate