Error: 3021 - No current record. -

imfarhan

Board Regular
Joined
Jan 29, 2010
Messages
123
Office Version
  1. 2016
Platform
  1. Windows
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-com:eek:ffice:eek:ffice" /><o:p>
'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:p>
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,215,454
Messages
6,124,931
Members
449,195
Latest member
Stevenciu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top