What am I doing wrong (easy). 
Author Message
 What am I doing wrong (easy).

I have the following code in the OnOpen of a report which divides certain text
boxes by twelve if the option group equals 2 on a dialog form.  This all works
fine.

Private Sub Report_Open(Cancel As Integer)
If Forms![A1-AvailDialogboxfrm]!Data = 2 Then
    DispOHUnits.ControlSource = "=OHUnits / 12"
    DispOpenProd.ControlSource = "=OpenProd / 12"
    DispTotalProd.ControlSource = "=TotalProd / 12"
    DispSalesTotalUnits.ControlSource = "=SalesTotalUnits / 12"
    DispSalesOpenUnits.ControlSource = "=SalesOpenUnits / 12"
    DispOpenToSell.ControlSource = "=OpenToSell / 12"
End If
End Sub

Now I want to divide by twelve one field in the subreport on the same report.
I put the following in the OnOpen of the subreport:

Private Sub Report_Open(Cancel As Integer)
If Forms![A1-AvailDialogboxfrm]!Data = 2 Then
    Units.ControlSource = "=ShipmentUnits / 12"
End If
End Sub

This does not work fine; I get this error:

Run-time error '2191':
You can't set the Control Source porperty after printing has started.
Try setting this property in the OnOpen event.

What am I doing wrong?  I am putting it in the OnOpen event.  If I should put
the code in the OnOpen event of the main report (and not the subreport), what
is that code.  I do not know how to reference another report.  Thanks in
advance.  I have been getting a lot of useful help on this report and this is
the last issue to be resolved.

Doyle60



Mon, 26 Jun 2000 03:00:00 GMT  
 What am I doing wrong (easy).

Try the following in the main report

Where
    Subreport is the name of the sub report control, not the name of the
report itself.

Private Sub Report_Open(Cancel As Integer)
If Forms![A1-AvailDialogboxfrm]!Data = 2 Then
'... Other code

    Me!Subreport.report!Units.ControlSource = "=ShipmentUnits / 12"
End If
End Sub

Quote:

>I have the following code in the OnOpen of a report which divides certain
text
>boxes by twelve if the option group equals 2 on a dialog form.  This all
works
>fine.

>Private Sub Report_Open(Cancel As Integer)
>If Forms![A1-AvailDialogboxfrm]!Data = 2 Then
>    DispOHUnits.ControlSource = "=OHUnits / 12"
>    DispOpenProd.ControlSource = "=OpenProd / 12"
>    DispTotalProd.ControlSource = "=TotalProd / 12"
>    DispSalesTotalUnits.ControlSource = "=SalesTotalUnits / 12"
>    DispSalesOpenUnits.ControlSource = "=SalesOpenUnits / 12"
>    DispOpenToSell.ControlSource = "=OpenToSell / 12"
>End If
>End Sub

>Now I want to divide by twelve one field in the subreport on the same
report.
>I put the following in the OnOpen of the subreport:

>Private Sub Report_Open(Cancel As Integer)
>If Forms![A1-AvailDialogboxfrm]!Data = 2 Then
>    Units.ControlSource = "=ShipmentUnits / 12"
>End If
>End Sub

>This does not work fine; I get this error:

>Run-time error '2191':
>You can't set the Control Source porperty after printing has started.
>Try setting this property in the OnOpen event.

>What am I doing wrong?  I am putting it in the OnOpen event.  If I should
put
>the code in the OnOpen event of the main report (and not the subreport),
what
>is that code.  I do not know how to reference another report.  Thanks in
>advance.  I have been getting a lot of useful help on this report and this
is
>the last issue to be resolved.

>Doyle60



Mon, 26 Jun 2000 03:00:00 GMT  
 What am I doing wrong (easy).

I am getting another error.  I now have the below in the OnOpen of the main
report (with no code in the subreport).  The line in question begins "Me!Avail.
. ." and is all on one line.

Private Sub Report_Open(Cancel As Integer)
If Forms![A1-AvailDialogboxfrm]!Data = 2 Then
    DispOHUnits.ControlSource = "=OHUnits / 12"
    DispOpenProd.ControlSource = "=OpenProd / 12"
    DispTotalProd.ControlSource = "=TotalProd / 12"
    DispSalesTotalUnits.ControlSource = "=SalesTotalUnits / 12"
    DispSalesOpenUnits.ControlSource = "=SalesOpenUnits / 12"
    DispOpenToSell.ControlSource = "=OpenToSell / 12"

    Me!AvailProdNeg1.Report!Units.ControlSource =                        
"=ShipmentUnits / 12"
End If
End Sub

The error reads:

Run-time error '2455':
You entered an expression that has an invalid referecne to the
property Form/Report.
The property may not exist or may not apply to the object you specified.

Remember the subreport control on the main form has a property SourceObject
(not ControlSource).  I tried to play with the line of code for an hour but
could not get anything out of it.  Are the ! and . correct?  I tried and
tried...  Thanks.

Doyle60

Terry responed:

Try the following in the main report

Where
    Subreport is the name of the sub report control, not the name of the
report itself.

Private Sub Report_Open(Cancel As Integer)
If Forms![A1-AvailDialogboxfrm]!Data = 2 Then
'... Other code

    Me!Subreport.report!Units.ControlSource = "=ShipmentUnits / 12"
End If
End Sub

Quote:

>I have the following code in the OnOpen of a report which divides certain
text
>boxes by twelve if the option group equals 2 on a dialog form.  This all
works
>fine.

>Private Sub Report_Open(Cancel As Integer)
>If Forms![A1-AvailDialogboxfrm]!Data = 2 Then
>    DispOHUnits.ControlSource = "=OHUnits / 12"
>    DispOpenProd.ControlSource = "=OpenProd / 12"
>    DispTotalProd.ControlSource = "=TotalProd / 12"
>    DispSalesTotalUnits.ControlSource = "=SalesTotalUnits / 12"
>    DispSalesOpenUnits.ControlSource = "=SalesOpenUnits / 12"
>    DispOpenToSell.ControlSource = "=OpenToSell / 12"
>End If
>End Sub

>Now I want to divide by twelve one field in the subreport on the same
report.
>I put the following in the OnOpen of the subreport:

>Private Sub Report_Open(Cancel As Integer)
>If Forms![A1-AvailDialogboxfrm]!Data = 2 Then
>    Units.ControlSource = "=ShipmentUnits / 12"
>End If
>End Sub

>This does not work fine; I get this error:

>Run-time error '2191':
>You can't set the Control Source porperty after printing has started.
>Try setting this property in the OnOpen event.

>What am I doing wrong?  I am putting it in the OnOpen event.  If I should
put
>the code in the OnOpen event of the main report (and not the subreport),
what
>is that code.  I do not know how to reference another report.  Thanks in
>advance.  I have been getting a lot of useful help on this report and this
is
>the last issue to be resolved.

>Doyle60



Mon, 26 Jun 2000 03:00:00 GMT  
 What am I doing wrong (easy).

What is AvailProdNeg1 ?

Is it the name of the report or the name of the Sub-report control (?)
these are not always the same.

It should be the Sub-Report controlname, when you go into design view on the
main report, click on the sub-report control and look at it's properties,
you should use the value next to the Name property.

This line translates (loosely) as meaning
    Me!AvailProdNeg1.Report!Units.ControlSource

Me => The current report
!AvailProdNeg1 => A control on the current report
.Report => Use the report properties/methods of the control
!Units => The field on the sub-report
.ControlSource => The control source of that field.

Quote:

>I am getting another error.  I now have the below in the OnOpen of the main
>report (with no code in the subreport).  The line in question begins
"Me!Avail.
>. ." and is all on one line.

>Private Sub Report_Open(Cancel As Integer)
>If Forms![A1-AvailDialogboxfrm]!Data = 2 Then
>    DispOHUnits.ControlSource = "=OHUnits / 12"
>    DispOpenProd.ControlSource = "=OpenProd / 12"
>    DispTotalProd.ControlSource = "=TotalProd / 12"
>    DispSalesTotalUnits.ControlSource = "=SalesTotalUnits / 12"
>    DispSalesOpenUnits.ControlSource = "=SalesOpenUnits / 12"
>    DispOpenToSell.ControlSource = "=OpenToSell / 12"

>    Me!AvailProdNeg1.Report!Units.ControlSource =
>"=ShipmentUnits / 12"
>End If
>End Sub

>The error reads:

>Run-time error '2455':
>You entered an expression that has an invalid referecne to the
>property Form/Report.
>The property may not exist or may not apply to the object you specified.

>Remember the subreport control on the main form has a property SourceObject
>(not ControlSource).  I tried to play with the line of code for an hour but
>could not get anything out of it.  Are the ! and . correct?  I tried and
>tried...  Thanks.

>Doyle60

>Terry responed:

>Try the following in the main report

>Where
>    Subreport is the name of the sub report control, not the name of the
>report itself.

>Private Sub Report_Open(Cancel As Integer)
>If Forms![A1-AvailDialogboxfrm]!Data = 2 Then
>'... Other code

>    Me!Subreport.report!Units.ControlSource = "=ShipmentUnits / 12"
>End If
>End Sub


>>I have the following code in the OnOpen of a report which divides certain
>text
>>boxes by twelve if the option group equals 2 on a dialog form.  This all
>works
>>fine.

>>Private Sub Report_Open(Cancel As Integer)
>>If Forms![A1-AvailDialogboxfrm]!Data = 2 Then
>>    DispOHUnits.ControlSource = "=OHUnits / 12"
>>    DispOpenProd.ControlSource = "=OpenProd / 12"
>>    DispTotalProd.ControlSource = "=TotalProd / 12"
>>    DispSalesTotalUnits.ControlSource = "=SalesTotalUnits / 12"
>>    DispSalesOpenUnits.ControlSource = "=SalesOpenUnits / 12"
>>    DispOpenToSell.ControlSource = "=OpenToSell / 12"
>>End If
>>End Sub

>>Now I want to divide by twelve one field in the subreport on the same
>report.
>>I put the following in the OnOpen of the subreport:

>>Private Sub Report_Open(Cancel As Integer)
>>If Forms![A1-AvailDialogboxfrm]!Data = 2 Then
>>    Units.ControlSource = "=ShipmentUnits / 12"
>>End If
>>End Sub

>>This does not work fine; I get this error:

>>Run-time error '2191':
>>You can't set the Control Source porperty after printing has started.
>>Try setting this property in the OnOpen event.

>>What am I doing wrong?  I am putting it in the OnOpen event.  If I should
>put
>>the code in the OnOpen event of the main report (and not the subreport),
>what
>>is that code.  I do not know how to reference another report.  Thanks in
>>advance.  I have been getting a lot of useful help on this report and this
>is
>>the last issue to be resolved.

>>Doyle60



Mon, 26 Jun 2000 03:00:00 GMT  
 What am I doing wrong (easy).

Terry, I did exactly what you said and correctly too.  The name of the
subreport control on the main form is AvailProdNeg1.  The name of the subreport
itself is A9-AvailProdNeg1rpt2.  The AvailProdNeg1 control has
Report.A9-AvailProdNeg1rpt2 in the Source Object property.  Please note that
this is a Source Object property and not a Control Source property.  I find it
hard to believe that Source Object is not part of your code.  I have been
playing around with your code in many ways but just can't get it.

I will try again but hoping you will respond again... Thanks for all your help.

Doyle60

What is AvailProdNeg1 ?

Is it the name of the report or the name of the Sub-report control (?)
these are not always the same.

It should be the Sub-Report controlname, when you go into design view on the
main report, click on the sub-report control and look at it's properties,
you should use the value next to the Name property.

This line translates (loosely) as meaning
    Me!AvailProdNeg1.Report!Units.ControlSource

Me => The current report
!AvailProdNeg1 => A control on the current report
.Report => Use the report properties/methods of the control
!Units => The field on the sub-report
.ControlSource => The control source of that field.



Tue, 27 Jun 2000 03:00:00 GMT  
 What am I doing wrong (easy).

Hi Doyle

Well., I've just knocked a sample database together based on your
information and I've ended up going back to what you had in the first place

'in the main report
Private Sub Report_Open(Cancel As Integer)
If Forms![A1-AvailDialogboxfrm]!Data = 2 Then
    DispOHUnits.ControlSource = "=OHUnits / 12"
    DispOpenProd.ControlSource = "=OpenProd / 12"
    DispTotalProd.ControlSource = "=TotalProd / 12"
    DispSalesTotalUnits.ControlSource = "=SalesTotalUnits / 12"
    DispSalesOpenUnits.ControlSource = "=SalesOpenUnits / 12"
    DispOpenToSell.ControlSource = "=OpenToSell / 12"
End If
End Sub

'in the sub report
Private Sub Report_Open(Cancel As Integer)
If Forms![A1-AvailDialogboxfrm]!Data = 2 Then
    Units.ControlSource = "=ShipmentUnits / 12"
End If
End Sub

This works with no errors.  This is very strange, I do not understand why we
are getting this difference in results.

I have tried this in both Access95 and Access97 and the above works.

Quote:

>Terry, I did exactly what you said and correctly too.  The name of the
>subreport control on the main form is AvailProdNeg1.  The name of the
subreport
>itself is A9-AvailProdNeg1rpt2.  The AvailProdNeg1 control has
>Report.A9-AvailProdNeg1rpt2 in the Source Object property.  Please note
that
>this is a Source Object property and not a Control Source property.  I find
it
>hard to believe that Source Object is not part of your code.  I have been
>playing around with your code in many ways but just can't get it.

>I will try again but hoping you will respond again... Thanks for all your
help.

>Doyle60


>What is AvailProdNeg1 ?

>Is it the name of the report or the name of the Sub-report control (?)
>these are not always the same.

>It should be the Sub-Report controlname, when you go into design view on
the
>main report, click on the sub-report control and look at it's properties,
>you should use the value next to the Name property.

>This line translates (loosely) as meaning
>    Me!AvailProdNeg1.Report!Units.ControlSource

>Me => The current report
>!AvailProdNeg1 => A control on the current report
>.Report => Use the report properties/methods of the control
>!Units => The field on the sub-report
>.ControlSource => The control source of that field.



Tue, 27 Jun 2000 03:00:00 GMT  
 What am I doing wrong (easy).

Terry,
Thanks for giving it a go.  I appreciate that.  I am glad to know that my
original idea was correct.  I am re-loading windows and Access today.  

I noticed that the word "ControlSource" does not come up on my list when
writing code.  Everything else does.  But it works when I type it.  Also,
everytime I go to the Web, my computer freezes.

Those and this new problem you have found, suggest it's time to re-load.  

After all this, if it still fails, I will try code that re-writes the subreport
queries.  Is that a good second choice?

Thanks again.

Doyle60



Mon, 03 Jul 2000 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Recordset: What am I doing wrong?

2. What am I doing wrong??

3. What am I doing wrong?

4. Help with syntax. What am I doing wrong

5. What am I doing wrong?

6. What am I doing wrong?

7. What am I doing wrong?

8. Please tell me what I am doing wrong - DAO parameter Append Query :(

9. What am I doing wrong? -MultiSelect List box

10. Select Case - What am I doing wrong?

11. OLE problem, or what am I doing wrong?

12. What am I doing wrong?

 

 
Powered by phpBB® Forum Software