Can't understand how it works......

A

Atlas

Access 2003 + sp1.

Now this.

I have a report whit group/detail sections. I need to print only ONE blank
line when a certain condition occurs in the detail section.

To acheive that I'm using a global var to store when the condition occurs so
the blank line is printed only once during the report printout.


This is what I coded:

** in the report's general section

Public myFlag As Integer


** in the report's open event

myFlag = 0


** in the report's detail format section

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If FormatCount = 1 Then
If someCondition = True And myFlag = 0 Then
myFlag = 1
Me.MoveLayout = True
Me.NextRecord = False
Me.PrintSection = False
End If
End If
End Sub

"Obviously" it doesn't work no line break occurs.

I've traced the detail_format sub: That's what's happening:

(BTW: the condition occurs on the third page)

1) the report execution starts
2) the detail_format sub is called multiple times
3) the condition occurs, (thus it looks like the formatting carries on for
the whole recordset) the line break code executed, myFlag is set to 1
4) program execution continues (other calls to the detail_format sub)
5) finally the first page is shown (preview)
6) next page is pressed
7) code execution starts again but myFlag is allready set to 1;


the line break will never be printed.

How can I bypass this unbeleivable problem?

Thanks
 
M

Marshall Barton

Atlas said:
Access 2003 + sp1.

Now this.

I have a report whit group/detail sections. I need to print only ONE blank
line when a certain condition occurs in the detail section.

To acheive that I'm using a global var to store when the condition occurs so
the blank line is printed only once during the report printout.


This is what I coded:

** in the report's general section

Public myFlag As Integer


** in the report's open event

myFlag = 0


** in the report's detail format section

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If FormatCount = 1 Then
If someCondition = True And myFlag = 0 Then
myFlag = 1
Me.MoveLayout = True
Me.NextRecord = False
Me.PrintSection = False
End If
End If
End Sub

"Obviously" it doesn't work no line break occurs.

I've traced the detail_format sub: That's what's happening:

(BTW: the condition occurs on the third page)

1) the report execution starts
2) the detail_format sub is called multiple times
3) the condition occurs, (thus it looks like the formatting carries on for
the whole recordset) the line break code executed, myFlag is set to 1
4) program execution continues (other calls to the detail_format sub)
5) finally the first page is shown (preview)
6) next page is pressed
7) code execution starts again but myFlag is allready set to 1;

the line break will never be printed.

How can I bypass this unbeleivable problem?


There is nothing obvious or unbelievable about this.

The only thing I can see that may be preventing the blank
detail from showing up is your check for FormatCount=1. Try
removing that and see what happens.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top