Function arguments

imfarhan

Board Regular
Joined
Jan 29, 2010
Messages
125
Office Version
  1. 2016
Platform
  1. Windows
Dear All
I'm using few functions to check if the file exist into particular directory or not... IF the file exist its ok otherwise ...the program should run in the loop and check again after 10 min "Wait 600" I've used followoing functions
The "Wait" function count seconds .....
The folllowing (3) function waitForInfoCom() doesn't go to "Wait 600" keep calling each other (3) and (4)j
don't know why .. appreciate your help plz.

1) FileFolderExists(strFullPath As String)
2) TestFileExistence() ' where keeep the path
3) WaitForInfoCom() ' This is where to check the timing .. further c
4) TestInfoCom() As ReturnStatus 'check if the record exist....

Note: some of the variable not using in the programme coz I copied from other application
some of the variable you may think not declare but they are enum which are as folllows
Public Enum ReturnStatus
FunctionFailed = -1
NothingToDo = 0
AllOK = 1
TimeToClose = 2
ActionRequired = 3
StopExecution = 4
End Enum

What I need to Do?
If the file doesn't found ... it shouldd wait for 10min and check again ....if the file has been copied or not furhter I would like to check multiple files instead of once....
Many thanks
Farhan
1)
Code:
    On Error GoTo EarlyExit
    If Not Dir(strFullPath, vbDirectory) = vbNullString Then FileFolderExists = True
 
EarlyExit:
    On Error GoTo 0
End Function
2)
Code:
Public Sub TestFileExistence() 'As ReturnStatus
    If FileFolderExists("T:\Info_Team\Farhan\Pathology\Pathology 201112\Data\axc.txt") Then
        MsgBox "File exists!"
    Else
        MsgBox "File does not exist!"
        Call WaitForInfoCom
    End If
3)

Private Function WaitForInfoCom() As ReturnStatus

'***************** Create Excel Report Pack
'Authog :
'Purpose :
'************************************************************************************************
Dim dInfoCom As Date
Dim bLate As Boolean, bNoConnection As Boolean
Dim a As Variant

On Error GoTo Err_Handler

'Check File copied in the folder or not

' Loop Until file has been copied
Do While TestInfoCom() = NothingToDo
'LogUpdate "Waiting for Infocom to finish", "M"
If Time > #8:00:00 AM# Then '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

ElseIf Time > #10:00:00 PM# Then
'Run out of time, quit out now
'LogUpdate "INFoCOM Running, too late today"
WaitForInfoCom = StopExecution
Exit Do

End If

'bNoConnection = False
Wait 600 ' 10 minutes
MsgBox "Waiting...."
' dInfoCom = DMax("Completed", tCHECK)

Loop
'dInfoCom = DMax("Completed", tCHECK)

'Log INFoCOM completion time
'LogUpdate "INFoCOM completed on " & dInfoCom

'Log a warning if INFoCOM has finished early

'If dInfoCom > Date & " 00:00" And dInfoCom < Date & " 05:00" Then
' LogUpdate "Warning - INFoCOM completed early - " & dInfoCom

'End If
'WaitForInfoCom = AllOK
Exit Function
Err_Handler:
If Err.Number = 3146 Or Err.Number = 3151 Then
'LogUpdate "Failed to contact InfoCom (Err: " & Err.Number & ") - Retrying"
WaitForInfoCom = NothingToDo
bNoConnection = True
Resume Next

Else
'LogUpdate "Error: " & Err.Number & " - " & Err.Description & " - WaitForInfoCom()"
WaitForInfoCom = FunctionFailed
End If
End Function

Code:
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("qryChkValue", dbOpenDynaset)
 
If rs.RecordCount = 0 Then
'Or format(rs.Fields("maxofend_dtime").Value,"YYYYMMDD") <> Format(Now(),"YYYYMMDD") 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
 
End Function
 
Last edited:

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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