我有一个Access 2010前端和sql2008。我在表单和报表的视图上使用日期参数。它没有给我任何数据。它不了解访问日期参数。我试过在sql中转换日期,但仍然没有数据。这是我正在使用的代码。
Private Sub Report_Open(Cancel As Integer)
LocationRpt
End Sub
Private Sub LocationRpt()
Dim frm As Form_frmSecRpt
Dim strSQL As String
Dim SchDt As Date
Set frm = Form_frmSecRpt
SchDt = frm.txtDate
strSQL = "Select * From vw_SecLocationWO Where ReSchDt =" & SchDt
Me.RecordSource = strSQL
End Sub
答案 0 :(得分:1)
Access SQL期望日期值用井号(#
)分隔,所以请尝试这样做:
strSQL = "SELECT * FROM vw_SecLocationWO WHERE ReSchDt = #" & Format(SchDt, "yyyy-mm-dd") & "#"