Extract records from Starting and Ending Date

  • Thread starter Thread starter Wahab
  • Start date Start date
W

Wahab

Please help me to take out records between 2 given dates
which is BeginningDate and EndingDate on form. I'm
writing SQL as follows :

Dim strSQL As String
strSQL = "SELECT * FROM Invoices WHERE [Date] Between
#" & [BeginningDate] & " # AND # " & [EndingDate] & "#"
Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL)
With rst
Do Until rst.EOF
.Edit
rst![InvPosted] = 1
.Update
.MoveNext
Loop
End With
rst.Close
Set db = Nothing
End Sub

This is not selecting correct dates. Please help me.
 
You are embedding some extra spaces. You might want to place a debug.print
strSQL and break point prior to the Set db... line. This way you can stop
and paste your SQL into a blank query to see what's going on.
 
Back
Top