Understanding On Format...

R

robc

I have written a report where different items are printed and the number of
lines printed varies based on LineType. I obviously have something wrong
here however... most of it appears to be working, however, when a LineType
"7" item is printed the GrossWeight column is Visible on the report.
Anyone know why ?

Also, does Access keep track internally when you print 3 rows for 1 line of
data (so it knows when to kick to the next page) ?

thanks !

The following is executed using the OnFormat Event...

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.LineType = "1" Then
' This does not print at all
Me.NComment.Visible = False
Me.NComment.Top = 0
Me.MShipQty.Visible = False
Me.MShipQty.Top = 0
' Want this to be 3 rows high
Me.Section(acDetail).Height = 720

' This goes on Line 1
Me.MStockCode.Visible = True
Me.MStockCode.Top = 0
Me.MStockDes.Visible = True
Me.MStockDes.Top = 0
Me.txtPackShipped.Visible = True
Me.txtPackShipped.Top = 0
Me.MCusSupStkCode.Visible = True
Me.MCusSupStkCode.Top = 0
Me.MOrderUom.Visible = True
Me.MOrderUom.Top = 0
Me.GrossWeight.Visible = True
Me.GrossWeight.Top = 0
Me.NetWeight.Visible = True
Me.NetWeight.Top = 0
Me.MPrice.Visible = True
Me.MPrice.Top = 0
Me.PlaceHolder.Visible = True

' This is on Line 2 within the section
Me.txtPackShipped.Top = 240
Me.MCusSupStkCode.Top = 240

' This is on Line 3 within the section
Me.PlaceHolder.Top = 480

ElseIf Me.LineType = "7" Then
' This does not print at all
Me.NComment.Visible = False
Me.NComment.Top = 0
Me.txtPackShipped.Visible = False
Me.txtPackShipped.Top = 0
Me.GrossWeight.Visible = False
Me.GrossWeight.Top = 0
Me.MCusSupStkCode.Visible = False
Me.MCusSupStkCode.Top = 0
Me.PlaceHolder.Visible = False
Me.PlaceHolder.Top = 0
Me.MPrice.Visible = False
Me.MPrice.Top = 0
Me.MOrderUom.Visible = False
Me.MOrderUom.Top = 0


' Want this to be 1 row high
Me.Section(acDetail).Height = 240

Me.MStockCode.Visible = True
Me.MStockCode.Top = 0
Me.MStockDes.Visible = True
Me.MStockDes.Top = 0
Me.MShipQty.Visible = True
Me.MShipQty.Top = 0
Me.MOrderUom.Visible = True
Me.MOrderUom.Top = 0
Me.NetWeight.Visible = True
Me.NetWeight.Top = 0

ElseIf Me.LineType = "6" Then

' This does not print at all
Me.MStockCode.Visible = False
Me.MStockCode.Top = 0
Me.MStockDes.Visible = False
Me.MStockDes.Top = 0
Me.txtPackShipped.Visible = False
Me.txtPackShipped.Top = 0
Me.MCusSupStkCode.Visible = False
Me.MCusSupStkCode.Top = 0
Me.PlaceHolder.Visible = False
Me.PlaceHolder.Top = 0
Me.MOrderUom.Visible = False
Me.MOrderUom.Top = 0
Me.GrossWeight.Visible = False
Me.GrossWeight.Top = 0
Me.NetWeight.Visible = False
Me.NetWeight.Top = 0
Me.MShipQty.Visible = False
Me.MShipQty.Top = 0
Me.MPrice.Visible = False
Me.MPrice.Top = 0
' Me.PackUOMShipped.Visible = False
' Me.PackDesc.Visible = False

' Want this to be 1 row high
Me.Section(acDetail).Height = 240

Me.NComment.Top = 0
Me.NComment.Visible = True

ElseIf Me.LineType = "5" Then

' This does not print at all
Me.MStockCode.Visible = False
Me.MStockCode.Top = 0
Me.MStockDes.Visible = False
Me.MStockDes.Top = 0
Me.txtPackShipped.Visible = False
Me.txtPackShipped.Top = 0
Me.MCusSupStkCode.Visible = False
Me.MCusSupStkCode.Top = 0
Me.PlaceHolder.Visible = False
Me.PlaceHolder.Top = 0
Me.MOrderUom.Visible = False
Me.MOrderUom.Top = 0
Me.GrossWeight.Visible = False
Me.GrossWeight.Top = 0
Me.NetWeight.Visible = False
Me.NetWeight.Top = 0
Me.MPrice.Visible = False
Me.MPrice.Top = 0
' Me.PackUOMShipped.Visible = False
' Me.PackDesc.Visible = False

' Want this to be 1 row high
Me.Section(acDetail).Height = 240


Me.NComment.Visible = True
Me.NComment.Top = 0
Me.MShipQty.Visible = True
Me.MShipQty.Top = 0
End If


End Sub
 
M

Marshall Barton

robc said:
I have written a report where different items are printed and the number of
lines printed varies based on LineType. I obviously have something wrong
here however... most of it appears to be working, however, when a LineType
"7" item is printed the GrossWeight column is Visible on the report.


I can't see anything that would cause the GrossWeight text
box to remain visible, unless the text box isn't really
named GrossWeight.

One thing that can mess up this approach is that Access
won't let you set the detail height above any control in the
section. I think you'll have to move all the controls' Top
to zero before setting the section's Height.

Also, does Access keep track internally when you print 3 rows for 1 line of
data (so it knows when to kick to the next page) ?

Yes. Access manages the space on the page and will start a
new page whenever needed.
 

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