数据类型 Number-Decimal [英] Data type Number-Decimal
问题描述
直到几天前一切正常,然后我遇到了这个问题.我在 Microsoft 365 中为 Access vba 编写了一些代码,这些代码在一些本地和连接的表上运行 SQL 查询.此连接表之一具有设置为数据类型 Number - Decimal 的字段.正如我所提到的,几天前这个字段开始返回空字符串.这是我尝试调查问题的几个步骤.
until few days ago everything was working fine and then I run into this problem. I wrote some code for Access vba in Microsoft 365 that run SQL query on some local and connected tables. One of this connected table has a field set as data type Number - Decimal. As I mention, few days ago this field start to return empty string. This are few steps I try to investigate the problem.
- 我制作了连接表的本地副本,以确保问题不是来自外部.没有区别
- 我创建了一个简单的查询访问 - SELECT * FROM [NameTable] 并且所有数据都在那里
- 我在 vba 中运行相同的查询,相关字段返回空字符串
我在 vba 中运行访问查询
- I made a local copy of the connected table to make sure the problem was not coming from outside. No difference
- I create a simple query access - SELECT * FROM [NameTable] and all the data were there
- I run the same query in vba and the field in question return an empty string
I run the access query within vba
Set qdfNew = dbs.QueryDefs("Pippo")
Set RS = qdfNew.OpenRecordset
If Not (RS.EOF And RS.BOF) Then
RS.MoveLast
RS.MoveFirst
For iCurRec = 0 To RS.RecordCount - 1
Debug.Print RS.Fields("HSL_QUANTITA").Value
RS.MoveNext
Next iCurRec
End If
RS.Close
它返回一个空字符串5. 我将表的数据类型更改为 Number - Integer、Long、Single 和 Double,在所有这些情况下,vba 中的查询都返回正确的值6.我是这样修改代码的
It returns an empty string 5. I change the data type of the table into Number - Integer, Long, Single and Double and in all these cases the query in vba return correct value 6. I modify the code in this way
Set qdfNew = dbs.QueryDefs("Pippo")
Set RS = qdfNew.OpenRecordset
If Not (RS.EOF And RS.BOF) Then
RS.MoveLast
RS.MoveFirst
For iCurRec = 0 To RS.RecordCount - 1
Debug.Print TypeName(RS.Fields("HSL_QUANTITA").Value)
RS.MoveNext
Next iCurRec
End If
RS.Close
在更改数据类型时,代码在直接窗口中返回:字符串 -> 数字 - 十进制Single -> Number-Single 精度Double -> Number-Double 精度整数 -> 数字-整数Long -> Number-Long
While changing the data type the code return in the immediate windows: String -> Number-Decimal Single -> Number-Single precision Double -> Number-Double precision Integer -> Number-Integer Long -> Number-Long
好像几天前 vba 不能再将十进制转换为字符串了
It looks like since few days ago vba cannot convert the decimal to a String anymore
我不拥有连接的表,因此我无法更改数据类型.我尝试向 Office 帮助台报告问题,但由于与 vba 相关,他们无法解决问题.
I do not own the connected table hence I cannot change the data type. I try to report the problem to the the Office help desk but they cannot solve the problem since is vba related.
有什么建议吗?
谢谢
推荐答案
您最近遇到了一个错误:
You have been hit by a recent bug:
请注意包含的临时解决方法链接.
Notice the included link for a temporary work-around.
这篇关于数据类型 Number-Decimal的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!