Basic QUery with Parameter taken from text field
Hello guys,
I've done this many times but somehow this one does not work...am I going insane?
Dim sql01, sql02 As String
sql01 = "SELECT * FROM CPOrganisation "
sql01 = sql01 & "WHERE (((CPOrganisation.DateEntered) Between #" & Me.txtBatchStartDate.Value
sql01 = sql01 & "# and #" & Me.txtBatchEndDate.Value & "#));"
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset(sql01)
if date i chose is 8/04/2010 (start date) and 8/04/2010 (end date) it produce nothing (MsgBox rst.RecordCount) I get zero
but in the QUery
SELECT *
FROM CPOrganisation
WHERE (((CPOrganisation.DateEntered) Between [Forms]![frmMain]![txtBatchStartDate] And [Forms]![frmMain]![txtBatchEndDate]));
it gives me the correct number (10 records enter for the date: 08/04/2010)
Anyone can shed light on this one? Thanks a lot guys!
Happy weekend everybody!!!
Hello guys,
I've done this many times but somehow this one does not work...am I going insane?
Dim sql01, sql02 As String
sql01 = "SELECT * FROM CPOrganisation "
sql01 = sql01 & "WHERE (((CPOrganisation.DateEntered) Between #" & Me.txtBatchStartDate.Value
sql01 = sql01 & "# and #" & Me.txtBatchEndDate.Value & "#));"
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset(sql01)
if date i chose is 8/04/2010 (start date) and 8/04/2010 (end date) it produce nothing (MsgBox rst.RecordCount) I get zero
but in the QUery
SELECT *
FROM CPOrganisation
WHERE (((CPOrganisation.DateEntered) Between [Forms]![frmMain]![txtBatchStartDate] And [Forms]![frmMain]![txtBatchEndDate]));
it gives me the correct number (10 records enter for the date: 08/04/2010)
Anyone can shed light on this one? Thanks a lot guys!

Happy weekend everybody!!!
