Extract records from Starting and Ending 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.
 
D

Duane Hookom

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top