在 VBA 中读取 RecordSet
我正在使用 MS ACCESS 2010,
我有一个表,其中员工 ID 和其他一些字段存储为
f123 - - -
f543 - - -
f654 - - -
f123 - - -
等。
'当我运行时,
strSQL="Select Distinct emp_id from Tbl"
Set rs = db.OpenRecordset(strSQL)
rs.MoveFirst
Do While Not rs.EOF
idVar = rs!Emp_Id
rs.MoveNext
Loop
记录集中获得的值是 123、543 等,而不是 <强>f123、f543等 当我在查询设计视图中运行查询时,它工作得很好。请帮忙。
I'm working on MS ACCESS 2010
I have a table in which employee id's and some other fields are stored as
f123 - - -
f543 - - -
f654 - - -
f123 - - -
etc.
'when i run
strSQL="Select Distinct emp_id from Tbl"
Set rs = db.OpenRecordset(strSQL)
rs.MoveFirst
Do While Not rs.EOF
idVar = rs!Emp_Id
rs.MoveNext
Loop
The values obtained in recordset are 123, 543 etc. instead of f123, f543 etc.
When i run the query in query design view it works perfectly. Pls help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
上面的代码不运行。下面的代码运行 - msgbox 包含用于测试值
Code above doesnt run. Code below runs - msgbox included to test values
我已经尝试重现这个问题,但恐怕没有成功。
请参阅屏幕转储。不确定这是否会对您有帮助。
谢谢马克

I have tried to recreate the problem without any success I'm afraid.
Please see screen dump. Not sure if this is going to help you though.
Thanks Mark
