Avatar of al4629740
Flag for United States of America

asked on 

Updating a database on Lost_Focus event in VB6

In VB6, on a form I'm opening a recordset to SQL in the following manner:

      rec.CursorType = adOpenKeyset
      rec.CursorLocation = adUseServer
      rec.LockType = adLockOptimistic
      rec.Open esql, conn, , , adCmdText

I then populate all the form text fields which works perfectly fine.  However, when I make a change to a text field, I created a LostFocus event that would save the record back to the table.  Here is the code for that:

Private Sub Text5_LostFocus()
rec!Name = Text5
End Sub

When that code for the LostFocus event occurs I receive an error on the first line rec!Name = Text5 :

What am I doing wrong?  All I want to do is make sure the form is updating the database each time a person makes a change on the form with the Lost Focus event.  

Visual Basic ClassicDatabasesMicrosoft SQL Server

Avatar of undefined
Last Comment

8/22/2022 - Mon