First Report always "true"

  • Thread starter Thread starter Bob Vance
  • Start date Start date
B

Bob Vance

Even when [tbCreditCard] is un-ticked the first report always prints Credit
card detail when all the rest dont print them!
Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)
On Error GoTo ProcError
If tbNoCreditCard = True Then



BoxC2.Visible = True
BoxC3.Visible = True
lbCreditCard.Visible = True
tbCreditCard2.Visible = True
tbCreditCard3.Visible = True
lbName.Visible = True
lbExpiry.Visible = True
lbSignature.Visible = True
Box136.Visible = True
Box137.Visible = True
Box138.Visible = True
Box139.Visible = True
Box140.Visible = True
Box142.Visible = True
Box143.Visible = True
Box144.Visible = True
Box145.Visible = True
Box146.Visible = True
Box147.Visible = True
Box148.Visible = True
Box149.Visible = True
Box150.Visible = True
Box152.Visible = True
Box153.Visible = True
Line169.Visible = True
Line191.Visible = True
Line170.Visible = True
Line196.Visible = True
BoxC2.Visible = True
BoxC3.Visible = True
lblTick.Visible = True
BoxC1.Visible = True
lblAmountpaid.Visible = True
tbCreditCard1.Visible = True

Else

BoxC2.Visible = False
BoxC3.Visible = False
lbCreditCard.Visible = False
tbCreditCard2.Visible = False
tbCreditCard3.Visible = False
lbName.Visible = False
lbExpiry.Visible = False
lbSignature.Visible = False
Box136.Visible = False
Box137.Visible = False
Box138.Visible = False
Box139.Visible = False
Box140.Visible = False
Box142.Visible = False
Box143.Visible = False
Box144.Visible = False
Box145.Visible = False
Box146.Visible = False
Box147.Visible = False
Box148.Visible = False
Box149.Visible = False
Box150.Visible = False
Box152.Visible = False
Box153.Visible = False
Line169.Visible = False
Line191.Visible = False
Line170.Visible = False
Line196.Visible = False
BoxC2.Visible = False
BoxC3.Visible = False
lblTick.Visible = False
BoxC1.Visible = False
lblAmountpaid.Visible = False
tbCreditCard1.Visible = False



ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure Detail_Format..."
Resume ExitProc
End If

End Sub
 
Are all those controls in the Page Footer? If they are in some other section,
then you should be using the format or print event of the section to set them
visible or not visible.

Also you could simplify that code quite a bit.

For instance drop the test and just use
BoxC2.Visible = tbNoCreditCard

Even better, I would select all the relevant controls and give them a taglike
ShowHide and then loop through the controls in the section checking the tag.
Something like the following code snippet

Dim ctl As Control
For each ctl in Me.Controls
If ctl.Tag = "ShowHide" then
ctl.Visible = tbNoCreditCard
End if
Next ctl

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Bob said:
Even when [tbCreditCard] is un-ticked the first report always prints Credit
card detail when all the rest dont print them!
Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)
On Error GoTo ProcError
If tbNoCreditCard = True Then



BoxC2.Visible = True
BoxC3.Visible = True
lbCreditCard.Visible = True
tbCreditCard2.Visible = True
tbCreditCard3.Visible = True
lbName.Visible = True
lbExpiry.Visible = True
lbSignature.Visible = True
Box136.Visible = True
Box137.Visible = True
Box138.Visible = True
Box139.Visible = True
Box140.Visible = True
Box142.Visible = True
Box143.Visible = True
Box144.Visible = True
Box145.Visible = True
Box146.Visible = True
Box147.Visible = True
Box148.Visible = True
Box149.Visible = True
Box150.Visible = True
Box152.Visible = True
Box153.Visible = True
Line169.Visible = True
Line191.Visible = True
Line170.Visible = True
Line196.Visible = True
BoxC2.Visible = True
BoxC3.Visible = True
lblTick.Visible = True
BoxC1.Visible = True
lblAmountpaid.Visible = True
tbCreditCard1.Visible = True

Else

BoxC2.Visible = False
BoxC3.Visible = False
lbCreditCard.Visible = False
tbCreditCard2.Visible = False
tbCreditCard3.Visible = False
lbName.Visible = False
lbExpiry.Visible = False
lbSignature.Visible = False
Box136.Visible = False
Box137.Visible = False
Box138.Visible = False
Box139.Visible = False
Box140.Visible = False
Box142.Visible = False
Box143.Visible = False
Box144.Visible = False
Box145.Visible = False
Box146.Visible = False
Box147.Visible = False
Box148.Visible = False
Box149.Visible = False
Box150.Visible = False
Box152.Visible = False
Box153.Visible = False
Line169.Visible = False
Line191.Visible = False
Line170.Visible = False
Line196.Visible = False
BoxC2.Visible = False
BoxC3.Visible = False
lblTick.Visible = False
BoxC1.Visible = False
lblAmountpaid.Visible = False
tbCreditCard1.Visible = False



ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure Detail_Format..."
Resume ExitProc
End If

End Sub
 
John Spencer said:
Are all those controls in the Page Footer? If they are in some other
section, then you should be using the format or print event of the section
to set them visible or not visible.

Also you could simplify that code quite a bit.

For instance drop the test and just use
BoxC2.Visible = tbNoCreditCard

Even better, I would select all the relevant controls and give them a
taglike
ShowHide and then loop through the controls in the section checking the
tag. Something like the following code snippet

Dim ctl As Control
For each ctl in Me.Controls
If ctl.Tag = "ShowHide" then
ctl.Visible = tbNoCreditCard
End if
Next ctl

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Bob Vance wrote:
Thanks John,That didnt work either way I tried
My code does work when I use the report to print one report
but when i use batch print (multiple) it fails always printing true on first
report
My report code:
Private Sub Report_Open(Cancel As Integer)

Me.tbOverDueAmount.ControlSource = "=iif(Nz(DSum('OwnerPercentAmount',
'tblInvoice', 'OwnerID =
Reports!rptOwnerPaymentMethodBatch![tbOwnerID].[value] and InvoiceDate < #"
& Format(Form_frmMain.tbFromDate.value, "MM/dd/yyyy") & "#'), 0) -
Nz(DSum('PaidAmount', 'tblAccountStatus', 'OwnerID =
Reports!rptOwnerPaymentMethodBatch![tbOwnerID].[value] and BillDate < #" &
Format(Form_frmMain.tbFromDate.value, "MM/dd/yyyy") & "#'), 0) = 0, " _
& "'(' & Nz(DSum('OwnerPercentAmount', 'tblInvoice', 'OwnerID =
Reports!rptOwnerPaymentMethodBatch![tbOwnerID].[value] and InvoiceDate < #"
& Format(Form_frmMain.tbFromDate.value, "MM/dd/yyyy") & "#'), 0) -
Nz(DSum('PaidAmount', 'tblAccountStatus', 'OwnerID =
Reports!rptOwnerPaymentMethodBatch![tbOwnerID].[value] and BillDate < #" &
Format(Form_frmMain.tbFromDate.value, "MM/dd/yyyy") & "#'), 0) &
')',Nz(DSum('OwnerPercentAmount', 'tblInvoice', 'OwnerID =
Reports!rptOwnerPaymentMethodBatch![tbOwnerID].[value] and InvoiceDate < #"
& Format(Form_frmMain.tbFromDate.value, "MM/dd/yyyy") & "#'), 0) -
Nz(DSum('PaidAmount', 'tblAccountStatus', 'OwnerID =
Reports!rptOwnerPaymentMethodBatch![tbOwnerID].[value] and BillDate < #" &
Format(Form_frmMain.tbFromDate.value, "MM/dd/yyyy") & "#'), 0))"
End Sub
 
Wow. That is UGLY and extremely difficult to understand.

And I don't understand how this relates back to hiding or showing some
controls in some section of your report.


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Bob said:
John Spencer said:
Are all those controls in the Page Footer? If they are in some other
section, then you should be using the format or print event of the section
to set them visible or not visible.

Also you could simplify that code quite a bit.

For instance drop the test and just use
BoxC2.Visible = tbNoCreditCard

Even better, I would select all the relevant controls and give them a
taglike
ShowHide and then loop through the controls in the section checking the
tag. Something like the following code snippet

Dim ctl As Control
For each ctl in Me.Controls
If ctl.Tag = "ShowHide" then
ctl.Visible = tbNoCreditCard
End if
Next ctl

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Bob Vance wrote:
Thanks John,That didnt work either way I tried
My code does work when I use the report to print one report
but when i use batch print (multiple) it fails always printing true on first
report
My report code:
Private Sub Report_Open(Cancel As Integer)

Me.tbOverDueAmount.ControlSource = "=iif(Nz(DSum('OwnerPercentAmount',
'tblInvoice', 'OwnerID =
Reports!rptOwnerPaymentMethodBatch![tbOwnerID].[value] and InvoiceDate < #"
& Format(Form_frmMain.tbFromDate.value, "MM/dd/yyyy") & "#'), 0) -
Nz(DSum('PaidAmount', 'tblAccountStatus', 'OwnerID =
Reports!rptOwnerPaymentMethodBatch![tbOwnerID].[value] and BillDate < #" &
Format(Form_frmMain.tbFromDate.value, "MM/dd/yyyy") & "#'), 0) = 0, " _
& "'(' & Nz(DSum('OwnerPercentAmount', 'tblInvoice', 'OwnerID =
Reports!rptOwnerPaymentMethodBatch![tbOwnerID].[value] and InvoiceDate < #"
& Format(Form_frmMain.tbFromDate.value, "MM/dd/yyyy") & "#'), 0) -
Nz(DSum('PaidAmount', 'tblAccountStatus', 'OwnerID =
Reports!rptOwnerPaymentMethodBatch![tbOwnerID].[value] and BillDate < #" &
Format(Form_frmMain.tbFromDate.value, "MM/dd/yyyy") & "#'), 0) &
')',Nz(DSum('OwnerPercentAmount', 'tblInvoice', 'OwnerID =
Reports!rptOwnerPaymentMethodBatch![tbOwnerID].[value] and InvoiceDate < #"
& Format(Form_frmMain.tbFromDate.value, "MM/dd/yyyy") & "#'), 0) -
Nz(DSum('PaidAmount', 'tblAccountStatus', 'OwnerID =
Reports!rptOwnerPaymentMethodBatch![tbOwnerID].[value] and BillDate < #" &
Format(Form_frmMain.tbFromDate.value, "MM/dd/yyyy") & "#'), 0))"
End Sub
 
Back
Top