I have created a report where I am using the "Detail_Format" event to generate what I want to display in my details section. I have created a temporary table that I am calling "Example Table" here and I am pulling my records from there. However, in order to be sure that I don't pull the same record twice, I am deleting records after I display them. The problem is that for every page the report generates the "Detail_Format"event appears to be called a final time where it goes through, gets the record, and deletes it, but does not display it on the report. Anybody know why that's happening? Anybody know what I can do about it?
[I have given a simplified version of what I was doing below. I may have left some minor details out, but hopefully it gives you a sufficient idea of what happened.]
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim dbs As Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset _
("SELECT *" & _
"FROM [ExampleTable] WHERE [ExampleField] LIKE '" & Somestring & "' ORDER BY [RandomIndex]")
With rst
.FindFirst "[ExampleField] LIKE '" & Somestring & "'"
If Not .NoMatch Then
ReportTextBox.Value = ![ExampleField]
.Delete
End If
End With
End Sub
[I have given a simplified version of what I was doing below. I may have left some minor details out, but hopefully it gives you a sufficient idea of what happened.]
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim dbs As Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset _
("SELECT *" & _
"FROM [ExampleTable] WHERE [ExampleField] LIKE '" & Somestring & "' ORDER BY [RandomIndex]")
With rst
.FindFirst "[ExampleField] LIKE '" & Somestring & "'"
If Not .NoMatch Then
ReportTextBox.Value = ![ExampleField]
.Delete
End If
End With
End Sub