在vba中设置通用数字格式 [英] Setting General Number Format in vba

查看:136
本文介绍了在vba中设置通用数字格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将一些新字段附加到vba中的表中,当我附加一个数字

字段时,它是一个字节,它不会继承任何格式。我希望它是

一般数字格式,但它是空白的。我尝试使用以下代码更改格式

,但它不起作用。这段代码出了什么问题

我怎么能让那个字节数字段有通用数字格式?


电话

SetPropertyDAO(DBEngine(0)(0).TableDefs(" tblCommen dations")。Fields(" Year"),

" Format",dbByte," General Number")


dixie

解决方案

从内存中,Format属性是dbText,而不是dbByte?


-

Allen Browne - 微软MVP。西澳大利亚珀斯

访问用户提示 - http:// allenbrowne .com / tips.html

回复群组,而不是mvps dot org的allenbrowne。


" Dixie" < di *** @ dogmail.com写信息

新闻:13 ************* @ corp.supernews.com ...
< blockquote class =post_quotes>
>我将一些新字段附加到vba中的表中,当我追加一个数字
字段是一个字节时,它不会继承任何格式。我希望它是
通用数字格式,但它是空白的。我试图用以下代码更改格式
,但它不起作用。这个
代码出了什么问题?如何让字节数字段具有通用号码格式?


电话

SetPropertyDAO(DBEngine(0)(0).TableDefs(" tblCommen dations")。Fields(" Year"),

" Format",dbByte," General Number")


dixie


那么如何将字节大小编号字段设置为通用编号?


dixie


" Allen Browne" < Al ********* @ SeeSig.Invalidwrote in message

news:46 ********************* *@per-qv1-newsreader-01.iinet.net.au ...


从内存中,Format属性是dbText,而不是dbByte?


-

Allen Browne - 微软MVP。西澳大利亚珀斯

访问用户提示 - http:// allenbrowne .com / tips.html

回复群组,而不是mvps dot org的allenbrowne。


" Dixie" < di *** @ dogmail.com写信息

新闻:13 ************* @ corp.supernews.com ...
< blockquote class =post_quotes>
>>我将一些新字段附加到vba中的表中,当我追加一个带字节的
数字字段时,它不会继承任何格式。我希望它是通用数字格式,但它是空白的。我试图使用以下代码更改
格式,但它不起作用。
此代码有什么问题?如何使该字节数字段具有General
数字格式?

调用
SetPropertyDAO(DBEngine(0)(0 ).TableDefs(" tblComme ndations")。Fields(" Year"),
" Format",dbByte," General Number")

dixie



3月27日,9:35 pm,Dixie < d ... @ dogmail.comwrote:


那么如何将字节大小编号字段设置为General Number?



嗨。


我不知道SetPropertyDAO应该是什么或做什么,但是要

更改本地字段属性这似乎有效。这是一个例子,

不适合你。如果该字段的格式不是先前设置的
,则可能需要首先使用Field.CreateProperty

创建。这将字节字段从货币格式更改为一般

数。


函数TestFldChange()

Dim db作为数据库

Dim tbl As TableDef

Dim fld As Field


设置db = CurrentDb

设置tbl = db.TableDefs(" tblTestTable")

设置fld = tbl.Fields(" TestFld")

fld.Properties(" Format")=" General号码

tbl.Fields.Refresh


设置fld = Nothing

设置tbl = Nothing

设置db = Nothing


结束功能


I am appending some new fields to a table in vba and when I append a number
field with is a byte, it does not inherit any format. I want it to be the
General Number format, but it is blank. I have tried to change the format
with the following code, but it does not work. What is wrong with this code
and how can I make that byte number field have the General Number format?

Call
SetPropertyDAO(DBEngine(0)(0).TableDefs("tblCommen dations").Fields("Year"),
"Format", dbByte, "General Number")

dixie

解决方案

From memory, the Format property is dbText, not dbByte?

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

"Dixie" <di***@dogmail.comwrote in message
news:13*************@corp.supernews.com...

>I am appending some new fields to a table in vba and when I append a number
field with is a byte, it does not inherit any format. I want it to be the
General Number format, but it is blank. I have tried to change the format
with the following code, but it does not work. What is wrong with this
code and how can I make that byte number field have the General Number
format?

Call
SetPropertyDAO(DBEngine(0)(0).TableDefs("tblCommen dations").Fields("Year"),
"Format", dbByte, "General Number")

dixie


So how do I set a byte size number field to General Number?

dixie

"Allen Browne" <Al*********@SeeSig.Invalidwrote in message
news:46**********************@per-qv1-newsreader-01.iinet.net.au...

From memory, the Format property is dbText, not dbByte?

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

"Dixie" <di***@dogmail.comwrote in message
news:13*************@corp.supernews.com...

>>I am appending some new fields to a table in vba and when I append a
number field with is a byte, it does not inherit any format. I want it to
be the General Number format, but it is blank. I have tried to change the
format with the following code, but it does not work. What is wrong with
this code and how can I make that byte number field have the General
Number format?

Call
SetPropertyDAO(DBEngine(0)(0).TableDefs("tblComme ndations").Fields("Year"),
"Format", dbByte, "General Number")

dixie



On Mar 27, 9:35 pm, "Dixie" <d...@dogmail.comwrote:

So how do I set a byte size number field to General Number?


Hi.

I have no idea what SetPropertyDAO is supposed to be or do, but to
change a local field property this seems to work. This is an example,
not intended to work as is for you. If the Format of the field was not
previously set, it may need to be created with Field.CreateProperty
first. This changed a byte field from a currency format to general
number.

Function TestFldChange()
Dim db As Database
Dim tbl As TableDef
Dim fld As Field

Set db = CurrentDb
Set tbl = db.TableDefs("tblTestTable")
Set fld = tbl.Fields("TestFld")
fld.Properties("Format") = "General Number"
tbl.Fields.Refresh

Set fld = Nothing
Set tbl = Nothing
Set db = Nothing

End Function


这篇关于在vba中设置通用数字格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆