Hi
I have inherit the automation system from some one, before its start its check if the entry occured in the table/query"qryTest_InfoCom_Completion" then the Automation should start its process other wise it shoud go in the waiting loop every 10min(WaitForInfoCom) function where TestInfoCom get called.
B4 it did made some changes in the code is as follow where one coditino runs ok when no record found but if the old date exist its runs where it shouldn't be run. so there are two check i want to use in the following code
1 = If no record found its shouldn't proceed &
2 = if the value in above mentioned table <> now()
The old code as follows where 1 condition works fine but not the 2nd condition.
Private Function TestInfoCom() As ReturnStatus
Dim rs As DAO.Recordset
'Dim dtMEnd_dtime As Date
On Error GoTo Err_Handler
'Check INFoCOM for the daily reports
Set rs = CurrentDb.OpenRecordset("qryTest_InfoCom_Completion", dbOpenDynaset)
'rs.MoveFirst
If rs.RecordCount = 0 Then
'Or Format(rs.Fields("maxofend_dtime").Value, "DD/MM/YYYY") <> Format(Now(), "DD/MM/YYYY") Then
'03/12/09 add the new check if date is not equal to today's date
'Not completed yet
rs.Close
Set rs = Nothing
TestInfoCom = NothingToDo
Exit Function
End If
rs.Close
Set rs = Nothing
TestInfoCom = ActionRequired
Exit Function
Err_Handler:
LogUpdate "Error: " & Err.Number & " - " & Err.Description & " - TestInfoCom()"
rs.Close
Set rs = Nothing
TestInfoCom = FunctionFailed
---
after enable the above red font line I got the following error and the automation kick of which shouldn't be.
Error: 3021 - No current record. - TestInfoCom()
I'm thinking to trap this errroy can I use the following code?
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o>
'Err_Handler:
' If Err.Number = 3021 Then
' LogUpdate "No Current Record Err: " & Err.Number & ") - Retrying"
' TestInfocom = NothingToDo
' bNoConnection = True
' Exit Function
' Else
' LogUpdate "Error: " & Err.Number & " - " & Err.Description & " - TestInfoCom()"
' rs.Close
' Set rs = Nothing
' TestInfoCom = FunctionFailed
' End If
Many thanks
I hope it does make sense to you if not please let me know.
values of varibale are as follows
Public Enum ReturnStatus
FunctionFailed = -1
NothingToDo = 0
AllOK = 1
TimeToClose = 2
ActionRequired = 3
StopExecution = 4
----
The main function where its called is follows:-
----
Private Function WaitForInfoCom() As ReturnStatus
Dim dInfoCom As Date
Dim bLate As Boolean, bNoConnection As Boolean
On Error GoTo Err_Handler
'Check INFoCOM for the daily reports
bNoConnection = False
' dInfoCom = DMax("Completed", tCHECK)
bLate = False
' Loop Until it's finished
Do While TestInfoCom() = NothingToDo
LogUpdate "Waiting for Infocom to finish", "M"
If Time > #8:00:00 AM# And bLate = False And bNoConnection = False Then
'Email out a message informing people that there will be a delay in creating reports
SendEmailWarning 86
bLate = True
......More...
</o>
I have inherit the automation system from some one, before its start its check if the entry occured in the table/query"qryTest_InfoCom_Completion" then the Automation should start its process other wise it shoud go in the waiting loop every 10min(WaitForInfoCom) function where TestInfoCom get called.
B4 it did made some changes in the code is as follow where one coditino runs ok when no record found but if the old date exist its runs where it shouldn't be run. so there are two check i want to use in the following code
1 = If no record found its shouldn't proceed &
2 = if the value in above mentioned table <> now()
The old code as follows where 1 condition works fine but not the 2nd condition.
Private Function TestInfoCom() As ReturnStatus
Dim rs As DAO.Recordset
'Dim dtMEnd_dtime As Date
On Error GoTo Err_Handler
'Check INFoCOM for the daily reports
Set rs = CurrentDb.OpenRecordset("qryTest_InfoCom_Completion", dbOpenDynaset)
'rs.MoveFirst
If rs.RecordCount = 0 Then
'Or Format(rs.Fields("maxofend_dtime").Value, "DD/MM/YYYY") <> Format(Now(), "DD/MM/YYYY") Then
'03/12/09 add the new check if date is not equal to today's date
'Not completed yet
rs.Close
Set rs = Nothing
TestInfoCom = NothingToDo
Exit Function
End If
rs.Close
Set rs = Nothing
TestInfoCom = ActionRequired
Exit Function
Err_Handler:
LogUpdate "Error: " & Err.Number & " - " & Err.Description & " - TestInfoCom()"
rs.Close
Set rs = Nothing
TestInfoCom = FunctionFailed
---
after enable the above red font line I got the following error and the automation kick of which shouldn't be.
Error: 3021 - No current record. - TestInfoCom()
I'm thinking to trap this errroy can I use the following code?
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o>
'Err_Handler:
' If Err.Number = 3021 Then
' LogUpdate "No Current Record Err: " & Err.Number & ") - Retrying"
' TestInfocom = NothingToDo
' bNoConnection = True
' Exit Function
' Else
' LogUpdate "Error: " & Err.Number & " - " & Err.Description & " - TestInfoCom()"
' rs.Close
' Set rs = Nothing
' TestInfoCom = FunctionFailed
' End If
Many thanks
I hope it does make sense to you if not please let me know.
values of varibale are as follows
Public Enum ReturnStatus
FunctionFailed = -1
NothingToDo = 0
AllOK = 1
TimeToClose = 2
ActionRequired = 3
StopExecution = 4
----
The main function where its called is follows:-
----
Private Function WaitForInfoCom() As ReturnStatus
Dim dInfoCom As Date
Dim bLate As Boolean, bNoConnection As Boolean
On Error GoTo Err_Handler
'Check INFoCOM for the daily reports
bNoConnection = False
' dInfoCom = DMax("Completed", tCHECK)
bLate = False
' Loop Until it's finished
Do While TestInfoCom() = NothingToDo
LogUpdate "Waiting for Infocom to finish", "M"
If Time > #8:00:00 AM# And bLate = False And bNoConnection = False Then
'Email out a message informing people that there will be a delay in creating reports
SendEmailWarning 86
bLate = True
......More...
</o>