looping issue

C

carrie schmid

May have the subject incorrect, but the following code will use the first
record, but won't move to the next record. Please help! thanks

Private Sub Command72_Click()
On Error GoTo Err_Command72_Click

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 browsername As String
Dim BrowserPath As String
Dim TableRS As Recordset
Dim MyDb As Database
Dim FileName As String
Dim namewait As String
Dim RetVal
Dim fs As Object

' 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
browsername = !browsername
BrowserPath = !BrowserPath
' DiscovererPath = "C:\orant\discvr31\dis31usr.exe"
' UserName = "MQKV54"
' Password = "xxxxxxxx"
' ConnectName = "kvhill02"
' browsername = "R010"
' BrowserPath = "c:\smart\"
End If
End With

' Set up filename of Excel file downloaded from the ARMS database

FileName = [BrowserPath] & "/" & [browsername] & ".xls"
namewait = [browsername] & "wait"
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 = "C:\orant\discvr31\dis31usr.exe /connect
MQKV54/xxxxxxxx@kvhill02 /open C:\DupsInARMS\DupsInARMS.dis /export xls
C:\DupsInARMS\DupsInARMS.xls /sheet all /batch"
' stAppName = [DiscovererPath] & " /connect " & [UserName] & "/" &
[Password] & "@" & [ConnectName] & " /open c:\DupsInARMS\DupsInARMS.dis
/export xls c:\DupsInARMS\DupsInARMS.xls /sheet all /batch"
' stAppName = [DiscovererPath] & " /connect " & [UserName] & "/" &
[Password] & "@" & [ConnectName] & " /open c:\DupsInARMS\DupsInARMS.dis
/export xls " & FileName & " /sheet all"
stAppName = [DiscovererPath] & " /connect " & [UserName] & "/" &
[Password] & "@" & [ConnectName] & " /open " & [BrowserPath] & "/" &
[browsername] & ".dis /export xls " & FileName & " /sheet all"
Call Shell(stAppName, 1)
' stAppName = Shell([DiscovererPath] & " /connect " & [UserName] & "/" &
[Password] & "@" & [ConnectName] & " /open c:\DupsInARMS\DupsInARMS.dis
/export xls c:\DupsInARMS\DupsInARMS.xls /sheet all /batch", 0)
' AppActivate stAppName
wait:
If fs.FileExists(FileName) Then
TableRS.MoveNext
Else: GoTo wait
End If




Exit_Command72_Click:

' DoCmd.Beep

TableRS.Close
MyDb.Close
MsgBox "Please be patient...this may take a few minutes. Exit Oracle
Discoverer when download is complete. Select OK to continue..."
If RetVal <> 0 Then
MsgBox "Download complete. Press any key to continue..."
End If
DoCmd.SetWarnings True

Exit Sub

Err_Command72_Click:
TableRS.Close
MyDb.Close
DoCmd.SetWarnings True
DoCmd.Beep
MsgBox "Make sure you entered a Password in Step 1 and your User Login
info is correct!"
' Resume Exit_Command72_Click

End Sub
 
M

Mike Painter

carrie said:
May have the subject incorrect, but the following code will use the
first record, but won't move to the next record. Please help! thanks
With TableRS
If Not .EOF Then
.MoveFirst
<snip>
You always start at the first record and never .movenext
 

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