Date Range Problem

Drunkenneo

Registered User.
Local time
Today, 23:06
Joined
Jun 4, 2013
Messages
192
I am trying to get the records on start and end date, still showing error no records found, Please help.

My code is like this:
Private Sub Command90_Click()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strReport As String

Const strcJetDate = "\#dd\/MM\/yyyy\#"

If (Text86.Value > Text88.Value) Then
MsgBox ("Enter Valid Period")
On Error GoTo ErrorHandlerExit
Else
Me.Form.RecordSource = "SELECT * FROM Master_Log WHERE date_processed BETWEEN " & Format(Me.Text86, strcJetDate) & " AND " & Format(Me.Text88, strcJetDate) & ""
'Me.Form.RecordSource = "SELECT * FROM Master_Log WHERE Date_Processed BETWEEN CDate(" & txt86.Value & ") AND CDate(" & txt88.Value & ");"
End If

On Error GoTo ErrorHandler
With Me.RecordsetClone
.MoveLast
'lblrec.Caption = .RecordCount
End With

If CurrentProject.AllReports(strReport).IsLoaded Then
DoCmd.Close acReport, strReport
End If


ErrorHandlerExit:
Exit Sub
ErrorHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & _
Err.Description
Resume ErrorHandlerExit
Text86.SetFocus
End Sub
 

Users who are viewing this thread

Back
Top Bottom