I have a problem with a VB6 app using a Access-MDB database.
A customer has the .MDB
and app .EXE
located on a network drive over a wifi network. On one of the workstations, when the app is invoked by a shortcut to the .EXE
on the network drive there are no errors, but when the app is installed and run locally on the workstation (with the .MDB
remaining on the network drive) there is an error.
Here is the relevant part of the code. The error message reported is "Unable to update at this time. Try again later."
Private Sub UpdateHistory()
Dim ecnt As Integer
Dim bInTrans As Boolean
On Error GoTo HistErr
bInTrans = False
ecnt = 0
Randomize
DBEngine.SetOption dbLockDelay, 90 + Rnd * 60
DBEngine.Idle dbRefreshCache
SWWorkspace.BeginTrans
If action = 1 Then
historyfile.AddNew
historyfile("customerid") = gblpkey
historyfile("operatorid") = CurrentOperator
historyfile("type") = gbltype
historyfile("date") = Format(Now, "dd/mm/yyyy hh:mm:ss")
If gbltype = 1 Or gbltype = 2 Or gbltype = 6 Then
historyfile("rtype") = "Manual"
End If
Else
historyfile.Edit
End If
saveDate = historyfile("date")
historyfile("memo") = ptext
historyfile.Update
SWWorkspace.CommitTrans dbForceOSFlush
bInTrans = False
Exit Sub
HistErr:
ecnt = ecnt + 1
If ecnt > 10 Then
If bInTrans Then
SWWorkspace.Rollback
bInTrans = False
End If
Screen.MousePointer = vbDefault
MsgBox "Unable to update at this time. Try again later. "
Exit Sub
End If
sleep 1
DBEngine.Idle dbRefreshCache
Resume
End Sub
The problem disappeared when I placed the EXE on the network drive and put a shortcut to it on the other workstation. I can only assume that invoking an EXE via a shortcut to a network location plays some part in preventing a wifi connection dropping out when accessing an MDB.