Use a IIf() expression, e.g.:
IIf(False, 0, Null)
False will never be true, so the zero will never be assigned, but the
presence of the alternative is enough to give JET a hint of the intended
data typel.
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Brian" <(E-Mail Removed)> wrote in message
news:4C8EEDDD-9679-4ECB-9456-(E-Mail Removed)...
>I have a union query that combines different types of account transactions
> (payments, invoices, and adjustments) for an account activity report.
>
> SELECT LookupAdjustment.*
> FROM LookupAdjustment
> UNION ALL
> SELECT LookupInvoice.*
> FROM LookupInvoice
> UNION ALL SELECT LookupPayment.*
> FROM LookupPayment;
>
> I have an InvoiceID field in each of the three source queries. It should
> be
> null for the adjustment and payment-related queries; however, when I enter
> it
> as Invoice: Null in those two, it results in "Data type mismatch in
> criteria
> expression) when running the UNION query. If I use Invoice:0 instead, it
> works, but then I have to convert the zeros or empty strings back to nulls
> in
> the report that uses the union query.
>
> Strangely, placing the invoice-related query as the first one in the UNION
> query allows me to use the nulls in the other two. Evidently, the UNION
> cannot handle a number in that field once it has inferred it at runtime to
> be
> a variant(?), but it can handle a null once it has inferred it to be a
> Long.
>