More info on my problem (and apologies for the long post):
I've found the underlying cause of my problem, but I'm still puzzled as to
why certain things happen, and how to best solve the problem.
Cause:
One of the linked Excel sheets contains cells with a space character, in a
column which should contain date entries. The linked table does not have a
problem with the datatype for this field (table design view of the linked
table show it to be a DateTime field), but it does show entries of #Num! for
the cells which contain a space character in the linked sheet.
Situation:
I am using links to the Excel sheets, not importing via code. The links use
the first row of the sheet as the field names.
The linked tables are used as the source for SELECT queries, which are then
combined in a Union query. Each Select query is similar to this (posted
previously, repeated here for convenience):
SELECT "Technical Reports" AS DocGroup, [Technical Reports].ID, [Technical
Reports].Title, [Technical Reports].[Author/Prepared By] AS Author,
IIf(CVDate([Planned Issue Date])>CVDate(nz([Actual Issue
Date],0)),CVDate([Planned Issue Date]),Null) AS NRDate, CVDate([Next Quality
Review Date]) AS NQRDate
FROM [Technical Reports]
WHERE ((([Technical Reports].ID) Is Not Null));
The #Num! error from the linked table propagates into the output of this
query. A dCount on this query (in the Immediate window on my home system)
runs OK (unlike the dCount on another query (see below), which fails on some
systems - the reason for my original post).
The Select query above is one of several which are combined in this Union
query:
SELECT * FROM qryDocPlans
UNION ALL
SELECT * FROM qryDocProcedures
UNION ALL
SELECT * FROM qryDocChecklists
UNION ALL
SELECT * FROM qryDocSpecifications
UNION ALL
SELECT * FROM qryDocTechNotes
UNION ALL
SELECT * FROM qryDocTechReports
UNION ALL
SELECT * FROM qryDocWorkInstructions;
This Union query fails to run, giving the "Data type mismatch in criteria
expression" error.
This Union query is used in the following Select query (also posted
previously, and again repeated here for convenience):
SELECT qryDocReview.DocGroup, qryDocReview.ID, qryDocReview.Title,
qryDocReview.Author, qryDocReview.NQRDate, tblDocQRevReminders.Printed
FROM qryDocReview LEFT JOIN tblDocQRevReminders ON (qryDocReview.NQRDate =
tblDocQRevReminders.NQRDate) AND (qryDocReview.ID = tblDocQRevReminders..ID)
WHERE (((tblDocQRevReminders.Printed)=False) AND
((DateAdd("d",-getconst("conDocRevRemind"),[qryDocReview].[NQRDate]))<=Date()))
OR (((tblDocQRevReminders.Printed) Is Null) AND
((DateAdd("d",-getconst("conDocRevRemind"),[qryDocReview].[NQRDate]))<=Date()))
ORDER BY qryDocReview.DocGroup, qryDocReview.ID;
This query does not fail on most of the systems I've tested it on, and a
dCount based on this query fails (with the "data type mismatch" error) on
some (but not all) systems.
Questions:
Why does the last query run on some systems and fail on some systems?
[Thought: is this possibly a Jet update/service pack issue?] And why, onat
least one system, does the query run but the dCount on the query fail?
How can I test for the #Num! entries (errors) in the first query (based on
the linked tables)? That would be the simplest method of preventing data
issues in the Excel sheets propagating into my queries, but I can't seem to
find anything that works - in particular, none of the error functions seem
to find anything wrong.
If I can't test for the #Num! entries in the linked tables, what other
alternatives do I have to solve this issue?
TIA,
Rob
Yes, the different machines are all running exactly the same .mdb file (I
copy the live file to my machine for testing/development - it's
essentially a single-user application), and the links to the various
spreadsheets are exactly the same. The sheets themselves are in a single
file on a server. The exception is the test copy on my home system, where
I found a problem with the datatype for the NQRDate in one of the linked
tables; I expect that is the same on the live system, but I will confirm
(and fix) if that's the case. And that may be in a few days, since I
won't be back to the work site probably until next week now.
Moreover, as I said in an my original post, the query itself runs OK on
the machine which throws the error with the dCount expression. And it's
that bit that still has me absolutely perplexed.
- Show quoted text -