Formatting a query field using code?

G

Guest

Hi,

I need to set the format property of a field in a query using VBA but I'm
not sure how to do it? I've tried this....

CurrentDb().QueryDefs("Custom_Sales_Query").Fields("Downloads").Properties("Format").Value = "Standard"

....but it doesn't seem to do anything? As you can see, the field
"Downloads" is the field I am trying to change. I want it to be displayed as
standard and no decimal places. I need it to change the query properties as
I'm not displaying the data on the form. As I can change the properties
manually in the query, I'm assuming I can also do it using code, but I code
above doesn't do anything (note - it doesn't actually crash, it just doesn't
format the field). I also need to make it 0 decimal places.

Really appreciate any help!
 
M

mcescher

Dim fld As DAO.Field
Set fld =
CurrentDb().QueryDefs("Custom_Sales_Query").Fields("Downloads")
fld.Properties("Format").Value = "Standard"
fld.Properties("DecimalPlaces").Value = 0

HTH,
Chris M.
 
G

Guest

To me this reads perfectly and is totally logical, but again it doesn't
actually do anything. I don't get an error but it doesn't work.

Thanks very much for the suggestion!

Any other views?
 
M

mcescher

Do you have to do it in code? Can you just go into the query and
change it? Does changing it to "Fixed" do anything different?

Is the field you're pulling a number or a string?

Formatting a text field as standard or fixed will not change work.
Only if the data is a number (integer, long, double, etc...)

HTH,
Chris M.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top