vba - DAO.Recordset 返回表名而不是列值
问题描述
原帖在这里。
只是想知道这里是否有人最近在 Access 2016/2019 中遇到过任何 DAO VBA 问题,其中相同的代码在 2007 年工作得很好。这个问题似乎在 6 月 10 日左右出现,但我似乎找不到任何 Windows 10/Office 2016/2019 Click-To-Run 更新与 DAO 参考特别相关。
编辑
这是原始代码,它在 Access 2016/2019 中提取表名,以代替 Access 2007 中的列值。此代码也用于提取 2016/2019 年的列值,但自 6 月 10 日以来就没有了, 2020:
'Declare stuff
DoCmd.SetWarnings False
Dim sReportType As String, sYear As String, SGroup As String, sGroupID As String, sGroupRptId2 As String
Dim sGLCode As String, sGLCodeStart As String, sGLCodeEnd As String
Dim sPeriod As String, sPeriodStart As String, sPeriodEnd As String
Dim sListInactiveAccts As String
Dim sRptTitleA As String
Dim sSQL As String
Dim DB As DAO.Database
Set DB = CurrentDb()
Dim Q As QueryDef
Set Q = DB.QueryDefs("G/L Trial Balance")
Dim localRS As DAO.Recordset, localRS2 As DAO.Recordset
'Determine year to use based on YearSelection drop-down
If Me.YearSelection = "Current year" Then 'If "Current Year" is selected, get the year of the current fiscal
sSQL = "SELECT a FROM table WHERE (((table.b)=""A""));"
Set localRS = DB.OpenRecordset(sSQL, dbOpenSnapshot)
sYear = localRS(0).Value
localRS.Close
ElseIf Me.YearSelection = "Prior year" Then 'If "Prior Year" is selected, ensure a year is entered in the "Prior Year:" text box
If IsNull(Me.PriorYearInput) Then 'If there isn't one, go to text box and notify end user
DoCmd.GoToControl "PriorYearInput"
MsgBox "Please enter a year in the ""Prior Year:"" field."
Exit Sub
Else 'If there is one, use it!
sYear = Me.PriorYearInput
End If
End If
MsgBox Me.YearSelection & ", " & sYear
解决方案
推荐阅读
- google-colaboratory - 在 colab 中访问已安装的谷歌驱动器上的文件时遇到问题
- tcl - TCL 脚本中的数组处理问题
- angular - Angular2 - 运行所有单元测试会失败一些单独通过的测试
- java - 防止 Android Studio Flutter 应用在拍照后关闭
- linux - 无法将 grep 用于命令并执行 shell 脚本?
- java - Optional.ifPresentOrElse 是否有任何编码风格指南?
- python - 如何只清除pyqt5中的图?
- python - pandas中选择部分数据的问题
- keycloak - Keycloak 自定义表单提供程序:表单的操作 url 错误
- c# - 在 Visual Studio 中查看派生类的扩展方法调用?