I am using the following pass-through query to MySQL(Tried it as a view as well with identical results) Everything is getting passed back correctly, except for the case result. MySQL returns the correct info, but Access can't seem to latch on to that.
I have to union it because the way data used to be stored is different from how it is currently stored. The problems seem to be with the case statement. MySQL returns proper values, i.e
but when Access tries to get at this data, the charge comes back as rectangle rectangle rectangle tilde tilde. I would like to be able to use this, and not do it in VBA. What's going on here?
Code:
select q.date_received
, q.quote_id
, q.distributor
, q.builder
, q.add1
, q.date_returned
, case
when q.Rate_ID = 0 then q.GlulamValue
when q.Rate_ID = 1 then q.GlulamValue
when q.Rate_ID = 2 then (q.fix_price + q.GlulamValue)
when (q.Rate_ID = 3
or q.Rate_ID = 4) then ((t.Rate_Charge * sum(h.hours)) + q.GlulamValue)
when q.Rate_ID = 5 then q.GlulamValue
when (q.Rate_ID >= 6 and q.Rate_ID <= 10) then ((t.Rate_Charge * sum(w.`Hours Worked`)) + q.GlulamValue)
else '0.00'
end as charge
from quotations AS q
left join HouseType AS h on h.quote_id = q.quote_id and h.deleted = 0
left join Billing AS b on b.Quote_ID = q.quote_id
left join hoursworked as w on h.ht_id = w.ht_id
left join rates as t on t.Rate_ID = q.Rate_ID
where q.builder is not null
and b.InvoiceNo = 'qre06-1123jm' [COLOR=green] InvoiceNo is the only part that gets changed [/color]
group by q.quote_id
UNION
select q.date_received
, q.quote_id
, d.Company AS Distributor
, bu.Company AS Builder
, q.add1
, q.date_returned
, case
when q.Rate_ID = 0 then q.GlulamValue
when q.Rate_ID = 1 then q.GlulamValue
when q.Rate_ID = 2 then (q.fix_price + q.GlulamValue)
when (q.Rate_ID = 3
or q.Rate_ID = 4) then ((t.Rate_Charge * sum(h.hours)) + q.GlulamValue)
when q.Rate_ID = 5 then q.GlulamValue
when (q.Rate_ID >= 6 and q.Rate_ID <= 10) then ((t.Rate_Charge * sum(w.`Hours Worked`)) + q.GlulamValue)
else '0.00'
end as charge
from quotations AS q
left join HouseType AS h on h.quote_id = q.quote_id and h.deleted = 0
left join companies AS bu on bu.Comp_ID = q.build_id
left join companies AS d on d.Comp_ID = q.dist_id
left join Billing AS b on b.Quote_ID = q.quote_id
left join hoursworked as w on h.ht_id = w.ht_id
left join rates as t on t.Rate_ID = q.Rate_ID
where (isnull(q.builder) or q.builder like '')
and b.InvoiceNo = 'qre06-1123jm' [COLOR=green] InvoiceNo is the only part that gets changed [/color]
group by q.quote_id
I have to union it because the way data used to be stored is different from how it is currently stored. The problems seem to be with the case statement. MySQL returns proper values, i.e
Code:
date_received quote_id distributor builder add1 date_returned charge
12/06/2008 2384 A A Builders A A Builders 12 17/06/2008 147500
but when Access tries to get at this data, the charge comes back as rectangle rectangle rectangle tilde tilde. I would like to be able to use this, and not do it in VBA. What's going on here?