DAO.Recordset возвращает имя таблицы вместо значения столбца - PullRequest
0 голосов
/ 17 июня 2020

Исходное сообщение здесь .

Просто интересно, были ли у кого-нибудь здесь недавние проблемы с DAO VBA в Access 2016/2019, где тот же код отлично работает в 2007 году. Кажется, эта проблема появились около 10 июня, но я не могу найти никаких обновлений Windows 10 / Office 2016/2019 Click-To-Run, специально связанных со ссылками на DAO.

EDIT

Вот исходный код, в котором он извлекает имя таблицы в Access 2016/2019 вместо значения столбца в Access 2007. Этот код также используется для извлечения значения столбца в 2016/2019, но это не так. t с ~ 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
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...