Thanks Allen , What should be ("Form1").??
Regards Bob Vance
Perhaps this is what you are seeking to do:
Private Sub Report_Open(Cancel As Integer)
Dim bHide As Boolean
If CurrentProject.AllForms("Form1").IsLoaded Then
If Forms("Form1")!tbAmountOne = 0 Then
bHide = True
End If
End If
Me.tb30day.Visible = Not bHide
Me.tb1Month.Visible = not bHide
'etc
End Sub
Thanks Allen, this is also part of my Report open, there isnt anything
I can alter here?
Just trying to get those 6 text boxes to not be visible if tbAmountOne
= zero....Thanks Bob
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))"
Thanks Allen, so can I write the code for my report from the control
that is to print the one report if tbAmountOne =0 and another report
if it does not?
Like :
Reports!rptOwnerPaymentMethodBatch!subChildOwnerInvoiceAmountBatchOne.Report!tbAmountOne
= 0 Then
DoCmd.OpenReport "rptOwnerPaymentMethodBatch", acNormal, , , ,
"Statement"
Else
DoCmd.OpenReport "rptOwnerPaymentMethodBatchOne", acNormal, , , ,
"Statement"
So it not a form; it's on a report?
That's not going to work. you cannot read a value off a report as
you can for a form. That's because of the way reports don't have a
'current' record in the same way forms do. The data is available in
the report's Format or Print event of the section that control, but
not afterwards.
I am getting runtime error 2455
You entered an expression that has an invalid reference to the
property Form/Report
Private Sub Report_Open(Cancel As Integer)
If
Reports!rptOwnerPaymentMethodBatch!subChildOwnerInvoiceAmountBatchOne.Report!tbAmountOne
= 0 Then
tb30day.Visible = False
tb1Month.Visible = False
tb60day.Visible = False
tb2Months.Visible = False
tb90day.Visible = False
tb3Months.Visible = False
Else
tb30day.Visible = True
tb1Month.Visible = True
tb60day.Visible = True
tb2Months.Visible = True
tb90day.Visible = True
tb3Months.Visible = True
End Sub
It is a SubForm of the Form that I am trying to locate! Thanks Bob
If subChildOwnerInvoiceAmountBatchOne is a subform on another
form, it won't be part of the Forms collection. You will need to
refer to it through its parent, e.g.:
If
Forms![YourMainFormNameHere]!subChildOwnerInvoiceAmountBatchOne.Form!tbAmountOne
= 0 Then
For an explanation of the ".Form" bit, see:
Referring to Controls on a Subform
at:
http://allenbrowne.com/casu-04.html
Of course, this assumes the form is open.
Also, if the tbAmountOne is null, the Else will execute.
Error say cant find "subChildOwnerInvoiceAmountBatchOne"
This being a subReport
Private Sub Report_Open(Cancel As Integer)
If Forms!subChildOwnerInvoiceAmountBatchOne!tbAmountOne = 0 Then
tb30day.Visible = False
tb1Month.Visible = False
tb60day.Visible = False
tb2Months.Visible = False
tb90day.Visible = False
tb3Months.Visible = False
Else
tb30day.Visible = True
tb1Month.Visible = True
tb60day.Visible = True
tb2Months.Visible = True
tb90day.Visible = True
tb3Months.Visible = True