On Format Event not executed

Len25

New member
Local time
Today, 13:13
Joined
Nov 29, 2007
Messages
4
Hi

I use the On Format event code if condition to hide fields from printing
But the code is not executed? The report prints all the fields?
 
Put a MsgBox in your code to see if it is executing. There could easily be something wrong with the logic of your code.
 
Posting the actual code would help us give an answer rather than guessing
 
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.PrintFlag Then
Me.Chqamt.Visible = True
Else
Me.Chqamt.Visible = False
End If
MsgBox " Printing"


End Sub

There is no respond from msgbox statement
 
I have the Debug on
"Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)" statement

But when I run the report, the debug is not triggered?
 
usually when this happens to me i have forgotten to change the properties for that event to "[Event Procedure]"
 
It sure sounds like something is not right. Have you tried a /decompile yet? How about importing everything into a fresh db?
 
I'm seeing the same thing with one of my office 2007 reports.

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    ' if restitution is > 0 then show it, otherwise hide it
    Debug.Print "Initial Appearance with Address: Detail Format: Restitution is " & Me![curCaseRestitution] & "."
    If (Me![curCaseRestitution] > 0) Then
        Me.lblRestitution.Visible = True
        Me.txtRestitution.Visible = True
    Else
        Me.lblRestitution.Visible = False
        Me.txtRestitution.Visible = False
    End If
    MsgBox ("In detail format.")
End Sub

The msgbox never displays and if I try to put a break point in the event it never gets triggered. I've confirmed the detail section of the report has the [Event Procedure] indicator and double clicking the ... on the property sheet does take me to the code. I've tried the decompile and I've also imported the database into a new front end.

Maybe I'm doing something wrong? In the report, if the record has any value other than 0 in the restitution, I want to display the textbox and label for that row. Otherwise I want to hide them. The textbox and label are in the detail section of the report but even if I don't have any code other than the msgbox it still never gets triggered.
 
Last edited:
I just realized that it is working correctly and hiding the field when I go to print preview, I was just looking at the Report View. <<bonks head>> Is there a way to hide it in report view too?
 

Users who are viewing this thread

Back
Top Bottom