My boss believes in simple is best so of course he wants everything done using one button. I have written the code that will run multiple things when the button is clicked but I wonder if I should use wait() or something more robust. What concerns me is the the files the button activates can change in size from one line of data to >500 lines of data and there isn't really a good way to set the time for the wait. Any suggestions.
Private Sub GetData_Click()
Dim strFilename As String
Dim strFilename2 As String
Dim strFilename3 As String
Dim strFilename4 As String
Dim objFS As Object
Dim objTS As Object
DoCmd.OpenQuery "CadCamHistory" 'Appends current data from CadCam table to CadCamHistory table.
Wait (5)
DoCmd.OpenQuery "MetalsaHistory" 'Appends current data from Metalsa table to MetalsaHistory table.
Wait (5)
DoCmd.OpenQuery "PurgeCadCamUtilities" 'Deletes current data from CadCamUtilities table.
Wait (5)
DoCmd.OpenQuery "PurgeMetalsaAccept" 'Deletes current data from MetalsaAccept table.
Wait (5)
Shell "Y:\K1\NCRails\Metalsa\Getdata.bat", vbNormalFocus 'runs a dos bat file that pulls data from a
Wait (30) 'vendor ftp site into our ftp site.
DoCmd.RunMacro "Macro1" 'runs the Macro that transfer 3 text files into 2 tables
Wait (50)
'--The next batch of code goes out to the ftp site and deletes the data in each of the text files.
Const For_Writing = 2
strFilename = "Y:\K1\NCRails\CADCAM\Renton.txt"
strFilename2 = "Y:\K1\NCRails\Metalsa\Renton.txt"
strFilename3 = "Y:\K1\NCRails\Metalsa\Output.txt"
strFilename4 = "Y:\K1\NCRails\CADCAM\RentonOther.txt"
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTS = objFS.OpenTextfile(strFilename, For_Writing)
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTS = objFS.OpenTextfile(strFilename2, For_Writing)
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTS = objFS.OpenTextfile(strFilename3, For_Writing)
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTS = objFS.OpenTextfile(strFilename4, For_Writing)
DoCmd.OpenQuery "NCBatchTest" 'runs a make table query
Wait (10)
DoCmd.OpenQuery "MetalsaAcceptTempMkTbl" 'runs a make table query
Wait (10)
DoCmd.OpenQuery "CadCamMkTbl" 'runs a make table query
Wait (10)
DoCmd.OpenQuery "UpdateBatchNC" 'runs an update query
Wait (10)
DoCmd.OpenQuery "UpdateNcSchAccept" 'runs an update query
Wait (10)
End Sub
Private Sub GetData_Click()
Dim strFilename As String
Dim strFilename2 As String
Dim strFilename3 As String
Dim strFilename4 As String
Dim objFS As Object
Dim objTS As Object
DoCmd.OpenQuery "CadCamHistory" 'Appends current data from CadCam table to CadCamHistory table.
Wait (5)
DoCmd.OpenQuery "MetalsaHistory" 'Appends current data from Metalsa table to MetalsaHistory table.
Wait (5)
DoCmd.OpenQuery "PurgeCadCamUtilities" 'Deletes current data from CadCamUtilities table.
Wait (5)
DoCmd.OpenQuery "PurgeMetalsaAccept" 'Deletes current data from MetalsaAccept table.
Wait (5)
Shell "Y:\K1\NCRails\Metalsa\Getdata.bat", vbNormalFocus 'runs a dos bat file that pulls data from a
Wait (30) 'vendor ftp site into our ftp site.
DoCmd.RunMacro "Macro1" 'runs the Macro that transfer 3 text files into 2 tables
Wait (50)
'--The next batch of code goes out to the ftp site and deletes the data in each of the text files.
Const For_Writing = 2
strFilename = "Y:\K1\NCRails\CADCAM\Renton.txt"
strFilename2 = "Y:\K1\NCRails\Metalsa\Renton.txt"
strFilename3 = "Y:\K1\NCRails\Metalsa\Output.txt"
strFilename4 = "Y:\K1\NCRails\CADCAM\RentonOther.txt"
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTS = objFS.OpenTextfile(strFilename, For_Writing)
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTS = objFS.OpenTextfile(strFilename2, For_Writing)
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTS = objFS.OpenTextfile(strFilename3, For_Writing)
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTS = objFS.OpenTextfile(strFilename4, For_Writing)
DoCmd.OpenQuery "NCBatchTest" 'runs a make table query
Wait (10)
DoCmd.OpenQuery "MetalsaAcceptTempMkTbl" 'runs a make table query
Wait (10)
DoCmd.OpenQuery "CadCamMkTbl" 'runs a make table query
Wait (10)
DoCmd.OpenQuery "UpdateBatchNC" 'runs an update query
Wait (10)
DoCmd.OpenQuery "UpdateNcSchAccept" 'runs an update query
Wait (10)
End Sub