-2

我有一个 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
4

1 回答 1

1

Access SQL expects date values to be delimited with hash marks (#), so try this instead:

strSQL = "SELECT * FROM vw_SecLocationWO WHERE ReSchDt = #" & Format(SchDt, "yyyy-mm-dd") & "#"
于 2013-09-20T22:24:32.310 回答