Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add custom format to number field with code 1

Status
Not open for further replies.

Eprice

Technical User
May 6, 2003
209
US
Hi,
Trying to add a custom format when I add a field to the table with vba. It is a number field that I want to force to two digits. Instead of 6 show 06, etc. I know how to add the field but not the format, I get errors with with this:

Set fld = tbl.CreateField("MYMYMYRevOR", dbLong, "00")
tbl.Fields.Append fld
fld.Properties("Format").Value = "00"

Is there a way to add a custom format to a number field? I would also like to be able to make the date fields 'ShortDate' but that does not work either.


Thanks
Lisa


 

hi,

06 is a STRING 'format' not a NUMBER format.

BTW, you can define the field as a number type, store the value 6, and then DISPLAY in a form or report as

Format([YourField],"00")

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Not really what I was looking for. It needs to be a number to compare with something else. I will just make them manually put the format in.
thanks anyway
Lisa
 



A NUMBER is a NUMBER

6 = 06 = 006 = 0006!!!

However if your have TEXT then the above equalities are NOT TRUE.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Lisa,

What Skip is trying to tell you is you should store your data properly.
Your users should NEVER see what's in the table. They will only see what you
show them in a form or report, which is where you FORMAT the data for DISPLAY purposes.


Randy
 
I understand the above and have made changes. Thank you
Lisa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top