Hi all,

I'm putting together a front-end for an Access '97 db using VB6.

I'm using the LostFocus event to save data to the db. The trouble is, when the cursor is in a text box, and the user clicks a menu item, it looks like the LostFocus event is not firing properly. Specifically, the data saving procedures are not working, because it seems the recordset is no longer available.

Is there any way to finish the LostFocus before going on to the menu command? I've tried DoEvents in the menu_click event, that doesn't seem to help.

thanks, Peter

VB Code:
  1. Public Sub txtTest_LostFocus(Index As Integer)
  2.  
  3.     DoEvents
  4.    
  5.     ' Two lots of text boxes, one for 'testwhat' and one (not visible)
  6.     ' for 'IDTest', to identify the current record
  7.  
  8.     ' Trim txtTest(Index), to trim, and to get rid of spaces
  9.     ' in an otherwise empty box
  10.     Trim (txtTest(Index).Text)
  11.    
  12.     ' If no text in the box, Delete
  13.     ' If text in the box, Edit-Update
  14.     If txtTest(Index).Text = "" Then
  15.         rstTests.FindFirst "IDTest = " & txtTestID(Index).Text
  16.         txtTestID(Index).Text = ""
  17.         rstTests.Delete
  18.     Else
  19.         rstTests.FindFirst "IDTest = " & txtTestID(Index).Text
  20.         rstTests.Edit
  21.         rstTests!testwhat = txtTest(Index).Text
  22.         rstTests.Update
  23.     End If
  24.    
  25. End Sub