Access交流中心

北京 | 上海 | 天津 | 重庆 | 广州 | 深圳 | 珠海 | 汕头 | 佛山 | 中山 | 东莞 | 南京 | 苏州 | 无锡 | 常州 | 南通 | 扬州 | 徐州 | 杭州 | 温州 | 宁波 | 台州 | 福州 | 厦门 | 泉州 | 龙岩 | 合肥 | 芜湖 | 成都 | 遂宁 | 长沙 | 株洲 | 湘潭 | 武汉 | 南昌 | 济南 | 青岛 | 烟台 | 潍坊 | 淄博 | 济宁 | 太原 | 郑州 | 石家庄 | 保定 | 唐山 | 西安 | 大连 | 沈阳 | 长春 | 昆明 | 兰州 | 哈尔滨 | 佳木斯 | 南宁 | 桂林 | 海口 | 贵阳 | 西宁 | 乌鲁木齐 | 包头 |

关于DCOUNT()请教大家

xbb  发表于:2018-08-26 12:43:08  
复制

前提:tblcodedbsj表中,存在dbid=071420141762,dbyearmonth=2018年08月,都为文本字段

Dim yearmonth As String
Dim txtdbid As String
Dim integerCount As Integer

yearmonth = "2018年08月"
txtdbid = "071420141762"

integerCount = DCount("*", "tblcodedbsj", "[dbid]='  "  &  txtdbid &  "  '  and [dbyearmonth]='  "  &  yearmonth & "  '  ")

MsgBox ("有" + CStr(integerCount) + "个记录" + "-" + txtdbid + "-" + yearmonth)
      
运行后,显示 "有0个记录-071420141762-2018年08月"

记录正确应该是1,但是这里是0,为什么会是0呢?

如果用RecordCount来写这段代码,应该如何写呢?


 

Top
郭长安 发表于:2018-08-26 20:22:00

我试了没问题:把空格去掉,写成

integerCount = DCount("*", "tblcodedbsj", "[dbid]=' " &txtdbid &"'  and [dbyearmonth]='"&yearmonth &"'")



总记录:1篇  页次:1/1 9 1 :