D
dhoover via AccessMonster.com
I'm using the code below to loop through records in a table, open a report
for the record selected, export the report and then loop back through for
each record in the table who has a statusid of 1. The problem is when the
code loops back thorough, it does not go to a new record, it just repeats the
process for the same record. What am I doing wrong?
On Error GoTo Err_cmdCustInfo_Click
Dim strCISFolderPath As String
Dim strFolder5 As String
Dim strFolderPath5 As String
strFolder5 = Dir(strFolderPath5, vbDirectory)
If CISFolderPath <> "" Then
strFolderPath5 = CISFolderPath
strFolder5 = Dir(strFolderPath5, vbDirectory)
End If
Dim rst As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb()
Set rst = db.OpenRecordset("Select * from [customer info]where statusid=1;")
With rst
If Not (.EOF And .BOF) Then
.MoveFirst
Do Until .EOF
DoCmd.OpenReport "Customer Instructions", acViewPreview, , "
[CustomerID]=" & [CustomerID]
DoCmd.OutputTo acOutputReport, "Customer Instructions", acFormatRTF,
strFolderPath5 & "\CIS.rtf", False
DoCmd.Close acOutputReport, "customer Instructions", False
.MoveNext
Loop
End If
.Close
End With
Set rst = Nothing
Set db = Nothing
for the record selected, export the report and then loop back through for
each record in the table who has a statusid of 1. The problem is when the
code loops back thorough, it does not go to a new record, it just repeats the
process for the same record. What am I doing wrong?
On Error GoTo Err_cmdCustInfo_Click
Dim strCISFolderPath As String
Dim strFolder5 As String
Dim strFolderPath5 As String
strFolder5 = Dir(strFolderPath5, vbDirectory)
If CISFolderPath <> "" Then
strFolderPath5 = CISFolderPath
strFolder5 = Dir(strFolderPath5, vbDirectory)
End If
Dim rst As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb()
Set rst = db.OpenRecordset("Select * from [customer info]where statusid=1;")
With rst
If Not (.EOF And .BOF) Then
.MoveFirst
Do Until .EOF
DoCmd.OpenReport "Customer Instructions", acViewPreview, , "
[CustomerID]=" & [CustomerID]
DoCmd.OutputTo acOutputReport, "Customer Instructions", acFormatRTF,
strFolderPath5 & "\CIS.rtf", False
DoCmd.Close acOutputReport, "customer Instructions", False
.MoveNext
Loop
End If
.Close
End With
Set rst = Nothing
Set db = Nothing