Hi RuralGuy!
Thanks for reply, I am not disabling the timer event while updating the database, actually this code is doing the following tasks:
1 - Call the function to backup the database every day on 3:00pm
2 - Call Function to Calculate the pending Request from user and show them on Admin panel
3 - Call the function when user read Admin message which is already sent by Admin to user
4 - If Message Receive from User then open the form a show the message and update the table that Admin read the msg.
5 - Call the function when user exit and Update the table
Code:
Private Sub Form_Timer()
On Error GoTo ErrorHandler
Call BackupDatabase ' Call the function to backup the database
Me!txtTotReq.Value = CountLocReq() & " Pending Req" ' Call Function to Calculate the pending Request from user and show them on Admin panel
If TempVars!gRead Then
Call MsgConfirm ' Call the function when user read Admin message which is already sent by Admin to user
If GotMessage() Then ' If Message Receive from User then open the form a show the message and update the table that Admin read the msg
Dim strSQL As String
Dim rs As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
strSQL = "SELECT ID, tmpFrom, tmpUserName, txtMessage, UserReadMsg From TempUser_T WHERE tmpUserName = '" & TempVars!gUserName & "'"
strSQL = strSQL + " AND UserReadMsg = False"
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
If rs.RecordCount > 0 Then
DoCmd.OpenForm "SendMsg_F"
Forms!SendMsg_F.txtMsgFrom.Value = rs!txtMessage
Forms!SendMsg_F.txtFrom.Value = rs!tmpFrom
Forms!SendMsg_F.cmbAdmin.Value = rs!tmpFrom
'chkmark for msg read
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE TempUser_T SET TempUser_T.UserReadMsg = -1 WHERE TempUser_T.ID = " & rs!ID
DoCmd.SetWarnings True
End If
rs.Close
Set rs = Nothing
End If
End If
If Exit_user() = True Then ' call the function when user exit and Update the table
Call SaveUserInfo("out") 'save user info
Application.Quit acSaveYes
End If
If Exit_all() = True Then ' function if all users want to be kickedd
Call SaveUserInfo("out") 'save user info
Application.Quit acSaveYes
End If
ExitProcedure:
Exit Sub
ErrorHandler:
DisplayError "Form_Timer", Me.Name
Resume ExitProcedure
End Sub
This Error comes only when there is a Network problem or Server is disconnected. Database need to re-establish the link and its only possible once you close the database and re-start the application.
So is there any way to re-link the tables without closing the database once ERROR 3034 occurs.
Many thanks
Khalid