Question : MsgBox firing twice during OnCurrent event ???

I have put in a MsgBox command in the DetailFormat event of my form.  The MsgBox displays the path to a linked picture which updates with every record.  

I would expect this MsgBox to appear once, but in fact it appears twice as I page through from one page to the next of my report.  It appears in a pattern something like this:

OnCurrent MsgBox displays: 1
OnCurrent MsgBox displays: 1-2
OnCurrent MsgBox displays: 2-3
OnCurrent MsgBox displays: 3-4
etc.

Basically, it seems to MsgBox the path to the object *about* to be displayed, and then it gives a MsgBox for the path of the object which is *next* to display.  Seems odd to me that it displays twice.

Can someone explain to me why it is happening twice?

Here is my complete code:

**************************************
Option Compare Database
Option Explicit

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If (Dir(OPTCPath & "03\Authorization\" & Me.[Roll#] & ".tif") <> "") Then
    Me![A].Picture = "Z:\03\Authorization\" & Me.[Roll#] & ".tif"
Else
    Me![A].Picture = ""
End If
MsgBox OPTCPath & Year & "\Authorization\" & Me.[Roll#] & ".tif"
End Sub

Private Sub Detail_Retreat()
Me![A].Picture = ""
End Sub

Answer : MsgBox firing twice during OnCurrent event ???

I'd go with nicos first as he posted before me-
As for my code, you'll need a new form dedicated to printing [or you can include it on an existing form] which has two textbox controls [default value 0] and a button to print the reports. Then you just add the code I provided to the click event of that button.

Dim runNo%
if RunNo%=1 then exit sub
txtTo.value=txtFrom.value+10
if txtTo.value>dmax("[anyfield]", "yourtable") then txtTo.value=dmax("[anyfield]", "yourtable") AND runNo%=1
textFrom.value=txtFrom.value+10
DoCmd.OpenReport "reportname", acNormal

Unlike Nicos code, this is on the proviso that your records have a number as their PK. The report uses a query to filter records >=txtFrom and
good luck

-0tacon-
Random Solutions  
 
programming4us programming4us