closing the StAppName

C

carrie schmid

I need each segment to close prior to the next opening. For Example R010
should disconnect from the Path, prior to AODate starting. THe code as is,
creates an error resulting in too many instances of the program attempting to
open at the same time.

If any could shed some light, I would appreciate it. Portion of code
follows. Thanks,
Carrie


DoCmd.SetWarnings False

' Set variables for program
Dim stAppName As String
Dim DiscovererPath As String
Dim UserName As String
Dim Password As String
Dim ConnectName As String
Dim TableName As String
Dim TableRS As Recordset
Dim MyDb As Database
Dim FileName As String
Dim RetVal
Dim fs As Object
Dim EPath As String

' Start adding records to database from Excel files

TableName = "WingInfo"

Set MyDb = CurrentDb
Set TableRS = MyDb.OpenRecordset(TableName, dbOpenSnapshot)

With TableRS
If Not .EOF Then
.MoveFirst
DiscovererPath = !DiscovererPath
UserName = !UserName
Password = !Password
ConnectName = !ConnectName
EPath = !EPath
' DiscovererPath = "C:\orant\discvr31\dis31usr.exe"
' UserName = "MQKV54"
' Password = "xxxxxxxx"
' ConnectName = "kvhill02"
End If
End With

' Set up filename of Excel file downloaded from the ARMS database
r010:
FileName = [EPath] & "\r010.xls"
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists(FileName) Then
fs.DeleteFile FileName
End If
' stAppName = "C:\DupsInARMS\Delete.bat"
' stAppName = "If Exist C:\DupsInARMS\DupsInARMS.xls Del
C:\DupsInARMS\DupsInARMS.xls /q"
' Call Shell(stAppName, 6)
stAppName = [DiscovererPath] & " /connect " & [UserName] & "/" & [Password]
& "@" & [ConnectName] & " /open c:\smart\r010.dis /export xls " & [EPath] &
"\r010.xls /sheet all /batch"
Call Shell(stAppName, 1)
r010wait:
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists(FileName) Then
GoTo personnel
Else: GoTo r010wait

personnel:
FileName = [EPath] & "\importpersonnel.xls"
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists(FileName) Then
fs.DeleteFile FileName
End If
stAppName = [DiscovererPath] & " /connect " & [UserName] & "/" & [Password]
& "@" & [ConnectName] & " /open c:\smart\importPERSONnEL.DIS /export xls " &
[EPath] & "\importPERSONnEL.xls /sheet all /batch"
Call Shell(stAppName, 1)
personnelwait:
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists(FileName) Then
GoTo aodate
Else: GoTo personnelwait

aodate:
FileName = [EPath] & "\aodate.xls"
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists(FileName) Then
fs.DeleteFile FileName
End If
stAppName = [DiscovererPath] & " /connect " & [UserName] & "/" & [Password]
& "@" & [ConnectName] & " /open c:\smart\aodate.DIS /export xls " & [EPath] &
"\aodate.xls /sheet all /batch"
Call Shell(stAppName, 1)
aodatewait:
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists(FileName) Then
GoTo fly
Else: GoTo aodatewait

fly:
FileName = [EPath] & "\fly.xls"
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists(FileName) Then
fs.DeleteFile FileName
End If
stAppName = [DiscovererPath] & " /connect " & [UserName] & "/" & [Password]
& "@" & [ConnectName] & " /open c:\smart\fly.DIS /export xls " & [EPath] &
"\fly.xls /sheet all /batch"
Call Shell(stAppName, 1)
flywait:
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists(FileName) Then
GoTo gnd
Else: GoTo flywait
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top