P
pubdude2003 via AccessMonster.com
I have seen a number of posts on this issue and I seem to have it coded
correctly but it just won't stop.
Static sfRunning As Boolean
sfRunning = True
Dim ID As Integer
Dim FileName As String
Dim SQLStmt As String
Dim SQLStmt2 As String
Dim rs As DAO.Recordset
Dim rs2 As DAO.Recordset
Dim db As DAO.Database
Dim RecordN As Integer
Dim counter1 As Integer
RecordN = 0
Set db = CurrentDb()
SQLStmt = "SELECT ID, FileName"
SQLStmt = SQLStmt & " FROM query1"
SQLStmt2 = "SELECT tblDirectory.FileName FROM tblDirectory INNER JOIN
Query4 ON tblDirectory.JustFile = Query4.FirstOfJustFile"
Set rs = db.OpenRecordset(SQLStmt)
Set rs2 = db.OpenRecordset(SQLStmt2)
rs.MoveLast
counter1 = rs.RecordCount
rs.MoveFirst
DoEvents
Do Until rs.EOF = True
DoEvents
If sfRunning = FalseThen
Exit Do
DoEvents
End If
RecordN = RecordN + 1
Me.Text38 = "Printing file " & (RecordN) & " of " & counter1
Requery
If rs!FileName = rs2!FileName Then
OpenAcrobat
PrintPDFDoc rs2!FileName
DoEvents
rs2.MoveNext
End If
OpenAcrobat
PrintPDFDoc2 rs!FileName
rs.MoveNext
DoEvents
Loop
Code to stop sfRunning
Sub cmdStart_Click()
With cmdStart
sfRunning = False
DoEvents
cmdStart.Caption = "Stopping"
DoEvents
End With
End Sub
Any insights would be appreciated
correctly but it just won't stop.
Static sfRunning As Boolean
sfRunning = True
Dim ID As Integer
Dim FileName As String
Dim SQLStmt As String
Dim SQLStmt2 As String
Dim rs As DAO.Recordset
Dim rs2 As DAO.Recordset
Dim db As DAO.Database
Dim RecordN As Integer
Dim counter1 As Integer
RecordN = 0
Set db = CurrentDb()
SQLStmt = "SELECT ID, FileName"
SQLStmt = SQLStmt & " FROM query1"
SQLStmt2 = "SELECT tblDirectory.FileName FROM tblDirectory INNER JOIN
Query4 ON tblDirectory.JustFile = Query4.FirstOfJustFile"
Set rs = db.OpenRecordset(SQLStmt)
Set rs2 = db.OpenRecordset(SQLStmt2)
rs.MoveLast
counter1 = rs.RecordCount
rs.MoveFirst
DoEvents
Do Until rs.EOF = True
DoEvents
If sfRunning = FalseThen
Exit Do
DoEvents
End If
RecordN = RecordN + 1
Me.Text38 = "Printing file " & (RecordN) & " of " & counter1
Requery
If rs!FileName = rs2!FileName Then
OpenAcrobat
PrintPDFDoc rs2!FileName
DoEvents
rs2.MoveNext
End If
OpenAcrobat
PrintPDFDoc2 rs!FileName
rs.MoveNext
DoEvents
Loop
Code to stop sfRunning
Sub cmdStart_Click()
With cmdStart
sfRunning = False
DoEvents
cmdStart.Caption = "Stopping"
DoEvents
End With
End Sub
Any insights would be appreciated