本文介绍了在vba中设置通用数字格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我将一些新字段附加到vba中的表中,当我附加一个数字 字段时,它是一个字节,它不会继承任何格式。我希望它是 一般数字格式,但它是空白的。我尝试使用以下代码更改格式 ,但它不起作用。这段代码出了什么问题 我怎么能让那个字节数字段有通用数字格式? 电话 SetPropertyDAO(DBEngine(0)(0).TableDefs(" tblCommen dations")。Fields(" Year"), " Format",dbByte," General Number") dixie 解决方案 嗨。 我不知道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 numberfield with is a byte, it does not inherit any format. I want it to be theGeneral Number format, but it is blank. I have tried to change the formatwith the following code, but it does not work. What is wrong with this codeand how can I make that byte number field have the General Number format? CallSetPropertyDAO(DBEngine(0)(0).TableDefs("tblCommen dations").Fields("Year"),"Format", dbByte, "General Number") dixie 解决方案 Hi. I have no idea what SetPropertyDAO is supposed to be or do, but tochange 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 notpreviously set, it may need to be created with Field.CreatePropertyfirst. This changed a byte field from a currency format to generalnumber. Function TestFldChange()Dim db As DatabaseDim tbl As TableDefDim fld As Field Set db = CurrentDbSet tbl = db.TableDefs("tblTestTable")Set fld = tbl.Fields("TestFld")fld.Properties("Format") = "General Number"tbl.Fields.Refresh Set fld = NothingSet tbl = NothingSet db = Nothing End Function 这篇关于在vba中设置通用数字格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-22 03:55