I must have made some global change, but don't remember what could have done this.
Suddenly after I make any DAO update or insert, (and I can do this by doing DAO.Recordset .Update, or .AddNew or dbTable.execute with a sql string)... when I requery the listbox, it doesn't refresh, I have to hit my Refresh button which does the same thing, requeries the list box (me.listbox.Requery) and maybe wait 2 or 3 seconds, then hit it again, then it refreshes.
What could cause this?
I put in a timer and the refresh happened fine.
None of this worked:
DoEvents
DBEngine.Idle dbRefreshCache
DoEvents
Me.Refresh
Me.lstDocstoVerify.RowSource = "qselEuniceEditCustomersDocumentsList"
If Me.Dirty Then
RunCommand acCmdSaveRecord
Finally this worked, changing the DAO.Recordset .Update to a sql query:
'Update tblContractFOFs
strSQL = "Update tblContractFOFs Set ReceivedDTS = Now(), ReceiverID = " & glngUserID & ", " & _
"ReceiveNotes = '" & Me.txtDocumentNotes & "', ModDTS = Now() " & _
"Where ContractFOFID = " & CLng(Nz(Me.lstDocstoVerify, 0))
CurrentDb.Execute strSQL
here's a sample code:
Private Sub cmdDocumentsVerify_Click()
Dim rst As DAO.Recordset
Dim varResult As VbMsgBoxResult
Dim varSCAPTransID As Variant
Dim lngSCAPTransID As Long
Dim fCOPrintOnly As Boolean
On Error GoTo Error_Handler
If glngUserID = 0 Then DoCmd.OpenForm FormName:="frmGetUser", WindowMode:=acDialog
If IsNull(Me.lstDocstoVerify) Then
MsgBox "Please select a Document to verify before continuing...", vbExclamation, "Attention!"
Me.lstDocstoVerify.SetFocus
Else
If IsNull(Me.txtDocumentNotes) Then
varResult = MsgBox("Would you like to enter a verification note before continuing?", vbQuestion + vbYesNoCancel + vbDefaultButton2, "Attention!")
Select Case varResult
Case vbYes
Me.txtDocumentNotes.SetFocus
Exit Sub
Case vbCancel
Exit Sub
End Select
End If
fCOPrintOnly = CBool(Me.lstDocstoVerify.Column(8))
'Update tblContractFOFs
Set rst = gdbTables.OpenRecordset("tblContractFOFs")
With rst
.Index = "ContractFOFID"
.Seek "=", CLng(Nz(Me.lstDocstoVerify, 0))
If Not .NoMatch Then
.Edit
If fCOPrintOnly Then !LastPrintDTS = Now()
!ReceivedDTS = Now()
!ReceiverID = glngUserID
!ReceiveNotes = Me.txtDocumentNotes
!ModDTS = Now()
.Update
End If
End With
...
cmdDocumentsRefresh_Click
End If
Exit_Error_Handler:
Exit Sub
Error_Handler:
Select Case Err.Number
Case INITIALIZE_GLOBALS_ERROR
InitializeGlobals
Resume
Case TYPE_MISMATCH
lngSCAPTransID = 0
Resume Next
Case Else
MsgBox "Error " & Err.Number & " : " & Err.Description, vbExclamation, "Error!"
Resume Exit_Error_Handler
End Select
End Sub
Private Sub cmdDocumentsRefresh_Click()
Me.lstDocstoVerify.Requery
Me.lstDocstoVerify = Null
Me.txtDocumentNotes = Null
End Sub