PC Review


Reply
Thread Tools Rate Thread

Currency Format Lost in Union Query

 
 
Jill
Guest
Posts: n/a
 
      27th May 2010
Thanks to John Spencer, I resolved one problem in my union query (Thank you,
John). But I have another problem. Some of my fields in my union query are
currencies and others percents. I see both formats are lost. I am sure it is
a union query problem, because when I ran an individual query, none of the
formats were lost. Is there any way I can keep currency and percent formats
without writing, FORMATCURRENCY, etc for each field?
Thank you.
 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      28th May 2010
What data types are these fields?

The field in a UNION query will normally take on the data type of the field
in the first SELECT. So, if the field in the first SELECT statement of the
UNION is of type Currency, the output field would most likely be of type
Currency as well, unless something else is going on (e.g. if it's a
calculated expression, or if there are many Nulls, or ...)

Since you can't use Design view, you cannot set the Format property with the
Properties box, but it is possible to set it programmaticallly. You could
use the SetPropertyDAO() function from this page:
http://allenbrowne.com/AppPrintMgtCo...SetPropertyDAO
like this:
call SetPropertyDAO(CurrentDb.QueryDefs("MyQuery").Fields("MyField"),
"Format", dbText, "Currency")

In the end, the Format doesn't matter. It's purely a display thing, and you
generally don't expose the table or query itself to an end user. The more
important thing is the data type of the field, and setting the Format
property won't achieve that. To test the data type, use something like this
in the Immediate Window:
? CurrentDb.QueryDefs("MyQuery").Fields("MyField").type
The result will be one of the numbes from the DAO column on this page:
http://allenbrowne.com/ser-49.html
or you can use the FieldTypeName() function here:
http://allenbrowne.com/func-06.html

HTH

--
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.


"Jill" <(E-Mail Removed)> wrote in message
news:793226F2-D606-4CC3-9297-(E-Mail Removed)...
> Thanks to John Spencer, I resolved one problem in my union query (Thank
> you,
> John). But I have another problem. Some of my fields in my union query are
> currencies and others percents. I see both formats are lost. I am sure it
> is
> a union query problem, because when I ran an individual query, none of the
> formats were lost. Is there any way I can keep currency and percent
> formats
> without writing, FORMATCURRENCY, etc for each field?
> Thank you.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel's financial currency format vs. Access currency format RoBo Microsoft Access Forms 0 4th Feb 2008 05:03 PM
A union B works, A union B union C fails Phil Smith Microsoft Access Queries 2 29th Nov 2006 06:50 PM
Union query screws currency format on report =?Utf-8?B?ZGVmYXVsdDEwNQ==?= Microsoft Access Reports 4 12th May 2006 10:46 PM
Union query screws currency format on report =?Utf-8?B?ZGVmYXVsdDEwNQ==?= Microsoft Access 4 12th May 2006 10:46 PM
To union query or not to union query =?Utf-8?B?U2V0aCBTY2h3YXJt?= Microsoft Access Queries 2 4th Feb 2005 11:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:56 AM.