07 doesn't find subreport object

N

NetworkTrade

The If/then below was developed in Access03 and works on machines with
Access03 but is throwing an error on the one machine with Access2007:

If Me.TollLotSubRpt.Report!CATtype2 = "n/a" Then
Me.TollLotSubRpt.Report!CATtype2.Visible = False
End If

The error is 'object not found'. It is not finding the
subreport control. This vb is in the Report's Detail 'OnFormat' event. I
deactivated the if/then code and the entire subreport area is blank.

working fine on the Access2003 machines...

Would welcome advice - plus as I do have to accommodate the 07 machine
ongoing if there is an outline of differences I would welcome a point of
reference on this. thanks
 
A

Allen Browne

The main report creates instances of the subreport as needed. You have a
timing problem by putting the code in the main report's module, i.e. the
relevant subreport may or may not be available, so your logic is flawed.

Move the code into the Format event of the section in the *subreport's*
module that contains the CATType2 field.
 
N

NetworkTrade

thanks. funny though I think I started (v1) with the vb in the subreport's
OnFormat but it did not work....so I moved it to the main form's subreport's
OnFormat where it did/does work - except on Access2007

but I did move to subreport as you point out....and it does work...so maybe
I am having a senior moment.... thanks again...my reference books have lots
of detail but never seem to point out practical architectural things such as
the instancing of subreports.....
--
NTC


Allen Browne said:
The main report creates instances of the subreport as needed. You have a
timing problem by putting the code in the main report's module, i.e. the
relevant subreport may or may not be available, so your logic is flawed.

Move the code into the Format event of the section in the *subreport's*
module that contains the CATType2 field.
 

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