A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Currency Format Lost in Union Query



 
 
Thread Tools Display Modes
  #1  
Old May 27th, 2010, 10:26 PM posted to microsoft.public.access.queries
Jill
external usenet poster
 
Posts: 166
Default Currency Format Lost in Union Query

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.
  #2  
Old May 28th, 2010, 03:42 AM posted to microsoft.public.access.queries
Allen Browne
external usenet poster
 
Posts: 11,706
Default Currency Format Lost in Union Query

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").Fiel ds("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").t ype
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 he
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" wrote in message
...
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.


 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:51 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.