Function, Call Function, Loop

imfarhan

Board Regular
Joined
Jan 29, 2010
Messages
123
Office Version
  1. 2016
Platform
  1. Windows
Hi All,
The following function working fine using RecordSet, its checking the files in the particular directory, If all the files found its fine , but If some file mising I call two functions GenerateEmail() and Wait(0 both functions are working fine
Problem?
How can I call the this function again? if all the files founds after wait function finishes, or when the global variale value sFNotFound <> -1 , because the variable value -1 its called two functions GenerateEmail and wait , want to run this function again after 10min
Do I have to use outer loo , or simply call this function again with the same function?

Many thanks


Code:
Public Function NameofDataFiles()
Dim rs As DAO.Recordset
Dim varFileName As String
Dim varFilePath As String
'Dim strFNotFound As String
GetLogs ' This function need to call at starting when Patholgy Automation start (PICS)
LogUpdate "Start looking DATA files of Pathology Monthly Loads............."
Set rs = CurrentDb.OpenRecordset("SELECT filename,path from ImportFileNames order by id")
 Do While Not rs.EOF
 
    varFileName = rs.Fields("FileName")
    varFilePath = rs.Fields("Path")
 
 'Call Function to check the file exist in the folder or not.
    Call TestFileExistence(varFileName, varFilePath) 'pass each FileName and path
    rs.MoveNext
Loop
   If sFNotFound = -1 Then
     Call GenerateEmail
[COLOR=sandybrown]    Wait 600   '600=10 minutes[/COLOR]
    End If
 
  rs.Close
 
 
End Function
Many thanks
FArhan
 
Last edited:

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Done!
Surprise I didn't know about that, we can call the same function where the acutual cursor is there... so the Answer is below:

Code:
Public Function NameofDataFiles()
 
....More code....
'Call Function to check the file exist in the folder or not.
 
Call TestFileExistence(varFileName, varFilePath) 'pass each FileName and path
    rs.MoveNext
Loop
   If sFNotFound = -1 Then
     Call GenerateEmail
     Wait 600   '600=10 minutes
    [COLOR=seagreen] Call NameofDataFiles[/COLOR]
    End If
 
Upvote 0

Forum statistics

Threads
1,215,509
Messages
6,125,216
Members
449,215
Latest member
texmansru47

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