Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extra call to Detail_Format event

Status
Not open for further replies.

itlotl

Programmer
Aug 26, 2005
5
US
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
 
This event fires a minimum of twice, and sometimes more depending on grouping in the report. Try moving your code to the detail print event....

The Microsoft mascot is a butterfly.
A butterfly is a bug.
Think about it....
 
Actually I tried that this morning just to see what would happen. For the most part it works great, except now, it's doing the same thing with the very first record in the whole report (and only with that record). Any idea how I could fix this?

Thanks for the help,
jt
 
I don't see why you would need to do this at all?

just make sure the query that you are bounding this report to has no duplicate entries...

--------------------
Procrastinate Now!
 
I wish it were that simple. Unfortunately, the query I'm binding the report to is only being used for the purpose of making sure the detail section is generated enough times. The actual data being displayed is selected and built by a whole bunch of logic that I couldn't make work in a SQL query. All of this seems to work just fine. In fact, it selects and builds the data appropriately for that first record. It just doesn't print it. That's the scoop. I'd appreciate any advice on the subject

Thanks again,
jt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top