Hi Folks,
With the help of experts here I've been able to produce the following code:
I have to produce this code for each instance of a text file and it's associated folder(s). which is in excess of 45 text files and folders and is likely to grow.
I understand that the code can be modified so that there is no need to have the above code mulitiple times. I need help in doing just that, as I don't know how to go about making the changes for that purpose.
A bit of background information may help you understand.
Text files are exported from a scanning system in fixed width format, but that scanning system doesn't keep a history for more than 48 hours. the nature of our work requires us to have the ability to revisit or indeed re-submit data to our main frame database should something go wrong, so hence the database solution for this.
Each day the respective manufacturer folders are checked for text files pertaining to that manufacturer, if a text files exists it is copied to our backup drive location to a folder with the exact same name, and the current date is added to the name of the text file, so that we can identify data according to the date it was exported from the scanning system.
The above code also counts the number of records in each text file if it exists and creates a record in the tblFileExists table each day.
So I need to modify the above code in a way that doesn't require it to be written mulitple times and removes the need to add more code when new manufacturers are added to the system.
Any help in this direction would be most appreciated.
John
With the help of experts here I've been able to produce the following code:
Code:
[FONT=Times New Roman][SIZE=3][/SIZE][COLOR=blue]
[SIZE=3][COLOR=#000000] [/COLOR][COLOR=blue][COLOR=#000000][COLOR=blue]If[/COLOR] FS.FileExists("B:\aeg.fof\aeg.txt") = [COLOR=blue]True Then[/COLOR]
FS.CopyFile "B:\aeg.fof\aeg.txt", "G:\Scan - Verify\eFlow\BackupProdRegOnprdfs01\aeg.fof\aeg " & "_" & Format(Date, "ddmmyy") & ".txt"
filenum = FreeFile
[COLOR=blue]Open[/COLOR] "B:\aeg.fof\aeg.txt" For Input As filenum
[COLOR=blue]Do While[/COLOR] Not EOF(filenum)
Line Input #filenum, tmp$
count = count + 1
[COLOR=blue]Loop[/COLOR]
[COLOR=blue]Close[/COLOR] #filenum
[COLOR=blue]Set[/COLOR] rst = DB.OpenRecordset("tblFileExists") [/COLOR][/COLOR][/SIZE]
[SIZE=3][COLOR=blue][COLOR=#000000] rst.AddNew
rst!strFileExists = "aeg.txt"
rst!lngRecordCount = count
rst.Update
rst.Close
[COLOR=blue]Set[/COLOR] rst = [COLOR=blue]Nothing[/COLOR]
count = 0
DoEvents
DoCmd.Echo [COLOR=blue]True[/COLOR], "Copying/Adding AEG Text File: " & "aeg.txt"
[/COLOR][COLOR=blue]End If[/COLOR][/COLOR][/SIZE]
[/COLOR][/FONT]
I have to produce this code for each instance of a text file and it's associated folder(s). which is in excess of 45 text files and folders and is likely to grow.
I understand that the code can be modified so that there is no need to have the above code mulitiple times. I need help in doing just that, as I don't know how to go about making the changes for that purpose.
A bit of background information may help you understand.
Text files are exported from a scanning system in fixed width format, but that scanning system doesn't keep a history for more than 48 hours. the nature of our work requires us to have the ability to revisit or indeed re-submit data to our main frame database should something go wrong, so hence the database solution for this.
Each day the respective manufacturer folders are checked for text files pertaining to that manufacturer, if a text files exists it is copied to our backup drive location to a folder with the exact same name, and the current date is added to the name of the text file, so that we can identify data according to the date it was exported from the scanning system.
The above code also counts the number of records in each text file if it exists and creates a record in the tblFileExists table each day.
So I need to modify the above code in a way that doesn't require it to be written mulitple times and removes the need to add more code when new manufacturers are added to the system.
Any help in this direction would be most appreciated.
John