访问 VBA 列表未填充数据

Access VBA List not populating Data

我有一个 Access VBA 列表框,其中的行源不会填充。它上周工作,本周重新打开数据库后,由于某种原因它不会显示我的字符串的结果。

Private Sub PullData(strType As String)
Dim rst As DAO.Recordset
Dim sSQL As String

On Error GoTo Err_PullData

Set rst = CurrentDb.OpenRecordset("SELECT * FROM TBLactionstaken_ARCHIVE", dbOpenDynaset, dbReadOnly)

Select Case strType

Case "Actions"
    
    If Me.Frame388.Value = 1 Then
        Me.lstActionsTaken.RowSource = "SELECT TBLactionstaken_ARCHIVE.RecordNumber, TBLactionstaken_ARCHIVE.ActionTakenID, TBLparticipants.[PartSS#], TBLactionstaken_ARCHIVE.ActionDate, TBLactionstaken_ARCHIVE.ActionStatus, TBLactionstaken_ARCHIVE.ReasonID, " & _
                                       "TBLreasons.Description, TBLactionstaken_ARCHIVE.MANHType, TBLactionstaken_ARCHIVE.ProcessedDate, TBLactionstaken_ARCHIVE.PayOutStatus, " & _
                                       "TBLactionstaken_ARCHIVE.PayOutDate FROM (TBLactionstaken_ARCHIVE INNER JOIN TBLparticipants ON TBLactionstaken_ARCHIVE.RecordNumber = " & _
                                       "TBLparticipants.RecordNumber) INNER JOIN TBLreasons ON TBLactionstaken_ARCHIVE.ReasonID = TBLreasons.ReasonID WHERE " & _
                                       "(((TBLactionstaken_ARCHIVE.ActionDate)<= [Form]![txtEndDate] And (TBLactionstaken_ARCHIVE.ActionDate)>= [Form]![txtEndDate]));"


          Me.lstActionsTaken.Requery
          
    ElseIf Me.Frame388.Value = 2 Then
        Me.lstActionsTaken.RowSource = ""
    Else
        MsgBox "No Data Available", vbExclamation, "Archive Search"
        Exit Sub
    End If

Case "Transactions"
    lstActionsTaken.Visible = False
    lstTransactions.Visible = True
    
End Select

Exit_PullData:

Exit Sub

Err_PullData:
    MsgBox Err.Description
    Resume Exit_PullData
    
End Sub

列表框设置为11列。它不会引发错误,我可以使用立即数 window 来确定我的字段具有值。

尝试使用特定格式的日期表达式:

    If Me.Frame388.Value = 1 Then
        Me.lstActionsTaken.RowSource = _
            "SELECT TBLactionstaken_ARCHIVE.RecordNumber, TBLactionstaken_ARCHIVE.ActionTakenID, TBLparticipants.[PartSS#], TBLactionstaken_ARCHIVE.ActionDate, TBLactionstaken_ARCHIVE.ActionStatus, TBLactionstaken_ARCHIVE.ReasonID, " & _
            "TBLreasons.Description, TBLactionstaken_ARCHIVE.MANHType, TBLactionstaken_ARCHIVE.ProcessedDate, TBLactionstaken_ARCHIVE.PayOutStatus, " & _
            "TBLactionstaken_ARCHIVE.PayOutDate FROM (TBLactionstaken_ARCHIVE INNER JOIN TBLparticipants ON TBLactionstaken_ARCHIVE.RecordNumber = " & _
            "TBLparticipants.RecordNumber) INNER JOIN TBLreasons ON TBLactionstaken_ARCHIVE.ReasonID = TBLreasons.ReasonID WHERE " & _
            "(TBLactionstaken_ARCHIVE.ActionDate <= #" & Format(Me!txtEndDate.Value, "yyyy\/mm\/dd") & "# And TBLactionstaken_ARCHIVE.ActionDate >= #" & Format(Me!txtEndDate.Value, "yyyy\/mm\/dd") & "#);"

' Not needed:          Me.lstActionsTaken.Requery