Whats wrong with my code!

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

Bob Vance

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



End Sub
 
On Sat, 8 Nov 2008 15:23:37 +1300, "Bob Vance" <[email protected]>
wrote:

Try this:
Me.subChildOwnerInvoiceAmountBatchOne.Report!tbAmountOne

-Tom.
Microsoft Access MVP
 
You say subChildOwnerInvoiceAmountBatchOne is a subreport? Then you can't
try to reference it through the Forms collection; you'd need to reference it
through the Reports collection, and through the main report's name:

Reports!MainReportName!SubReportName!ControlNameOnSubReport

If it is a subreport, what is your code trying to do with a subreport's
control's value in the main report's Open event? A subreport's control's
value most likely is not going to be accessible when the main report's Open
event occurs.
 
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.
 
On Fri, 7 Nov 2008 22:18:17 -0500, "Ken Snell \(MVP\)"

Sorry, I think that should be:
Reports!MainReportName!SubReportName.Report!ControlNameOnSubReport

-Tom.
 
It is a SubForm of the Form that I am trying to locate! Thanks Bob

Allen Browne said:
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.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Bob Vance said:
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



End Sub
 
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

Bob Vance said:
It is a SubForm of the Form that I am trying to locate! Thanks Bob

Allen Browne said:
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.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Bob Vance said:
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



End Sub
 
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.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Bob Vance said:
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

Bob Vance said:
It is a SubForm of the Form that I am trying to locate! Thanks Bob

Allen Browne said:
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



End Sub
 
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"

Allen Browne said:
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.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Bob Vance said:
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

Bob Vance said:
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



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))"
Bob Vance said:
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"

Allen Browne said:
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.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Bob Vance said:
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



End Sub
 
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

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Bob Vance said:
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))"
Bob Vance said:
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"

Allen Browne said:
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.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

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



End Sub
 
Thanks Allen , What should be ("Form1").??
Regards Bob Vance

Allen Browne said:
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

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Bob Vance said:
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))"
Bob Vance said:
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.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

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



End Sub
 
Form1 is the name of the form that contains the tbAmountOne text box you
want to look at when the report opens.

If it's a subform, you will need the full reference as shown previously.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Bob Vance said:
Thanks Allen , What should be ("Form1").??
Regards Bob Vance

Allen Browne said:
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

Bob Vance said:
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
 
Sorry Allen, this is a Report! Thanks Bob

Allen Browne said:
Form1 is the name of the form that contains the tbAmountOne text box you
want to look at when the report opens.

If it's a subform, you will need the full reference as shown previously.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Bob Vance said:
Thanks Allen , What should be ("Form1").??
Regards Bob Vance

Allen Browne said:
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
 
Thanks Allen, I am getting error "Object closed or does not exist
Regards Bob

Dim bHide As Boolean

If
CurrentProject.AllReports("subChildOwnerInvoiceAmountBatchOne").IsLoaded
Then
If Reports("subChildOwnerInvoiceAmountBatchOne")!tbAmountOne = 0
Then
bHide = True
End If
End If

Me.tb30day.Visible = Not bHide
Me.tb1Month.Visible = Not bHide
Me.tb60day.Visible = Not bHide
Me.tb2Months.Visible = Not bHide
Me.tb90day.Visible = Not bHide
Me.tb3Months.Visible = Not bHide
Allen Browne said:
Form1 is the name of the form that contains the tbAmountOne text box you
want to look at when the report opens.

If it's a subform, you will need the full reference as shown previously.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Bob Vance said:
Thanks Allen , What should be ("Form1").??
Regards Bob Vance

Allen Browne said:
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
 
Bob, please go back and read the replies you have been given.

We explained why you cannot read this value in Report_Open if it's on a
report (too early), and you cannot read it from the the report after it has
run (too late.)

You can only read the value in the Format or Print event of the section that
contains the control.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Bob Vance said:
Sorry Allen, this is a Report! Thanks Bob

Allen Browne said:
Form1 is the name of the form that contains the tbAmountOne text box you
want to look at when the report opens.

If it's a subform, you will need the full reference as shown previously.

Bob Vance said:
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
 

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

Similar Threads


Back
Top