Nick, the code as you presented it should not crash Access assuming that
it
is in the Format event of the section that contains the 6 controls, and
the
section is tall and wide enough to handle it.
But Access 2007 is very flakey, especially with code in the report
events.
I'm aware of several scenarios that will bring it crashing down, so I'm
not
surprised if you have another.
This assumes it's not merely a NameAutoCorrect bug, or bad binary
(decompile.)
Very flakey in what area?
Why should some every simple code that moves a few controls around
'For x = 0 To 6
' With Me.Controls(OrderedControls(x))
' .Visible = True 'screw with visible controls only
' .Top = x * 0.0021 * 1440
' .Height = 0.0021 * 1440
' End With
'Next x
cause one of the control to open without its valid recordset, and hang
the
debugger and app?
Nick
:
Okay, we know A2007 is very flakey in this area, so it sounds like you
are
progressively zero-ing in on the code that is triggering the crash.
Now, with that portion of the code commented out, I can get the
report
to
Print Preview. Attempting to right-click and move to Design View
immediately
crashes the app, however....
Nick
:
Okay: no outer joins, so the yes/no fields will not cause the
problem.
You are actually changing the SourceObject of the subreport in the
events
of
the main report? That would have to be the number one suspect for
what
is
crashing Access 2007. Could you comment out that code temporarily,
and
see
if the crashes stop?
You know, I have never really understood what is meant by an
'outer
join.'
I
see errors occasionally regarding "Access cannot evaluate
ambigous
outer
joins, do one first and then another...' but other than that, I
never
see
that syntax.
The query in question is:
SELECT tblInsDetails.JobID, tblInsDetails.OwnerID,
tblInsDetails.ConsigneeID, tblInsDetails.InsTypeID,
tblInsDetails.InsLocationID, tblInsDetails.InspectorID,
tblInsDetails.InspectorID2, tblInsDetails.InspectorID3,
tblInsDetails.InspectorID4, tblInsDetails.InspectorID5,
tblInsDetails.Date,
tblInsDetails.[WO#], tblInsDetails.[PO#],
tblInsTypes.InsTypeName,
tblInsTypes.[Eng Certification], tblInsTypes.[Capacity Rating],
tblCertResults.Item, tblCertResults.Make,
tblCertResults.SerialNumber,
tblCertResults.Model, tblCertResults.Unit,
tblCertResults.Capacity,
tblCertResults.Comments, tblInsDetails.WOPrinted,
tblCertResults.[Re-CertPeriod], tblCertResults.RP,
tblCertResults.RepairedBy,
tblCertResults.LetterCertItem, tblClients.[Cert Address 1],
tblClients.[Cert
Address 2], tblClients.[Cert City], tblClients.[Cert Province],
tblClients.[Cert Postal Code], tblInsDetails.EngPO,
tblInsDetails.CertPrinted,
tblCertStatus.AdditionalInspectionInfo,
tblCertStatus.AdditionalDisclaimerInfo,
tblCertStatus.AdditionalCapacityInfo,
tblCertResults.[10YearBoomCert], tblInsLocations.LocationName,
tblCertResults.GeneralEquipTypeID, tblClients_1.AllCertsSentHere,
tblClients_1.[Client Name], tblInsDetails.Notes
FROM ((tblClients AS tblClients_1 INNER JOIN ((tblInsTypes INNER
JOIN
(tblClients INNER JOIN tblInsDetails ON tblClients.[Client ID] =
tblInsDetails.OwnerID) ON tblInsTypes.InsTypeID =
tblInsDetails.InsTypeID)
INNER JOIN tblInsLocations ON tblInsDetails.InsLocationID =
tblInsLocations.InsLocationID) ON tblClients_1.[Client ID] =
tblInsDetails.ConsigneeID) INNER JOIN tblCertResults ON
tblInsDetails.JobID =
tblCertResults.JobID) INNER JOIN tblCertStatus ON
tblCertResults.ResultsID
=
tblCertStatus.ResultsID
WHERE (((tblInsDetails.JobID)=[forms]![frmJobID]![jobid]));
There are Boolean fields invovled, but the SQL has no "outer
join'
in
its
syntax. The sub report cannot be dumped, because, depending on
the
data,
the
source object may get swapped out to a completely different
subreport.
Very
flexible, but it can sometimes get a little snaky debugging it
when
the
source object causing problems isn't the one you think it is
![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
None
of
that
is one the go with the record set involved here though. It is
just
weird.
The query loads data for the main report, heck, I put a
docmd.openquery
"thatquery" line in the detail_format event that hangs the
app--the
query
loads, but the subreport still insists there is no current
record.
The
child
and master fields are good. They are linked by the autonumber
field
of
the
main lookup table--no better pedigree than that. I'll look at
the
arrticle
you mentioned.
Thanks
Nick
:
Okay, so you have identified that the problem does relate to the
code
in
the
report's events. (Access doesn't fire this code in Report or
Layout
view.)
You might check the LinkMasterFields/LinkChilds properties of
the
subreport
control to ensure this is correct.
The No Current Record error could be triggered by some code that
deleted
the
current record (unlikely.) It could also be bogus. For example,
if
the
report's source is a query that uses outer joins, and the table
has
any
yes/no fields, you may have hit this bug:
Outer join queries fail on Yes/No fields
at:
http://allenbrowne.com/bug-14.html
If the main report and subreport are both the same and filtered
to
the
same
record, you may be able to dump the subreport. Instead, you
could
create
a
Group Footer on the primary key field within the main report. Of
course
this
will occur for every record, and you could place whatever you
have
in
the
subreport in this section of the main report instead.
message
I have separated the required objects out and put them into a
DB
that
I
can
post. It will open in every mode EXCEPT print preview in
Access
2007
(although just what use Layout and Report views will be
remains
to
be
seen...with this particular report, those views look so
garbled
that
I
wouldn't touch an object in them
![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
) The report's behavior is
this:
Both
the report and one of its sub-report use the same query for a
datasource.
That query returns records, yet the print preview throws an
error
claiming
'no cuurent record' for the subreport. The debugger opens. A
truly
annoying
behavior then happens. Mousing over any variable that should
have
been
set
by the recordset generates a popup 'no current record' (how do
I
turn
that
off--its very annoying). When the debugger is closed, a
message
occurs
that
a failure in a routine is preventing the report from being
formatted,
and
the
app hangs. I will check the kb article you mentioned.