export to rtf not correct (or same file exported)

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 10:30
Joined
Nov 8, 2005
Messages
3,309
a very bland heading I know
I have this report that needs to be export - 1 report per record
the report exports out but its the same record export out each time ( the name changes - but the data doesn't)
i am sure it simplies - but not seeing it ?
(I have tried the code down - as there was a lot of junk int here re emailing - but thats a side issue :banghead:
-
Private Sub Command0_Click()


Dim MyDb As DAO.Database
Dim rsemail As DAO.Recordset


Dim RefernceNumber As String

Dim FilenameZ As String
Set MyDb = CurrentDb()
Set rsemail = MyDb.OpenRecordset("bondqry", dbOpenSnapshot)
Dim FilterZ As String
Dim strID As String
Dim i As Integer


For i = 0 To rsemail.RecordCount


rsemail.MoveNext
Next i




'DoCmd.OutputTo acOutputReport, "Reportname", acFormatRTF, "S:\Test Data\xxxx\Policy\" &.Fields(6) & ".Doc", False

With rsemail
.MoveFirst



Do Until rsemail.EOF
strID = rsemail.Fields(6)


DoCmd.OpenReport "Bondreport", acViewPreview, , "RefernceNumber=" & rsemail.Fields(6) & ""

DoCmd.OutputTo acOutputReport, , acFormatRTF, "c:\Test\" & .Fields(6) & ".Doc", False

If IsNull(.Fields(11)) = False Then
sToName = .Fields(11)
sSubject = "whatever: " & "stuff"
sMessageBody = "Email Body Text "



End If


.MoveNext
Loop
End With

Set MyDb = Nothing
Set rsemail = Nothin
 
I recall recently researching a similar issue with dbOpenSnapshot:
https://msdn.microsoft.com/en-us/library/office/ff197799.aspx says:

•Snapshot-type Recordset— a static copy of a set of records that you can use to find data or generate reports. A snapshot-type Recordset object can contain fields from one or more tables in a database but can't be updated. This type corresponds to an ODBC static cursor.

So maybe your cursor needs to move and dbOpenSnapShot is not moving
Maybe try dbOpenDynaset

Just a guess...
Let us know if that has any beneficial effect or not

Cheers,
Goh
 
cheers I try that - it late here UK time
one for Monday

G
 
You never close the report, so the first one opened will keep being used. It needs to be closed after the OutputTo line.
 
Well blow me down
as simples as Pbaldy said

Thanks to you both
what i will do is get this tidied up (I putting an email function in as well)
and put it up as a sample

Big thanks

G
 

Users who are viewing this thread

Back
Top Bottom