Sub Teste012374901247()
Const SQL As String = _
"SELECT t.* " & _
"FROM tbl2000 As t " & _
"WHERE t.LC = p0 " & _
"ORDER BY t.Date"
With CurrentDb.CreateQueryDef("", SQL)
.Parameters("p0") = dat(0)
With .OpenRecordset
[COLOR="Green"] 'do something with the recordset[/COLOR]
.Close
End With
.Close
End With
End Sub
What doesn't work about what I posted?Shall we continue or bale out. I don't know if this is getting anywhere.
I'm not sure what it should do either. This is all you've given us to go on...I'm not sure what it should do.
Presumably you want to be able to replace dat(0) with text that may contain delimiters, and I have shown how I would do that."Select * From tbl2000 where LC = '" & dat(0) & "' Order by tbl2000.Date"
Function GetRecordset(LC As <whattypeisLC?>) As DAO.Recordset
Const SQL As String = _
"SELECT t.* " & _
"FROM tbl2000 As t " & _
"WHERE t.LC = p0 " & _
"ORDER BY t.Date"
With CurrentDb.CreateQueryDef("", SQL)
.Parameters("p0") = LC
Set GetRecordset = .OpenRecordset
.Close
End With
End Sub
MyDateField <= "#4/5/2018#" AND MyOtherField = "MyValueHere"