The Date Box jpg is the code that i pulled from another site and I am hoping to incorporate the rest of the code into that button. Please help, I've been trying to figure this out for months.
Expand|Select|Wrap|Line Numbers
- Private Sub Submit_Click()
- On Error GoTo Err_Handler
- Dim strReport As String
- Dim strDateField As String
- Dim strWhere As String
- Dim lngView As Long
- Const strcJetDate = "\#mm\/dd\/yyyy\#"
- strReport = "Search"
- strDateField = "[Date]"
- lngView = acViewReport
- If IsDate(Me.startdate) Then strWhere = "(" & strDateField & " >= " & Format(Me.startdate, strcJetDate) & ")"
- End If
- If IsDate(Me.enddate) Then
- If strWhere <> vbNullString Then
- strWhere = strWhere & " AND "
- End If
- strWhere = strWhere & "(" & strDateField & " < " & Format(Me.enddate + 1, strcJetDate) & ")"
- End If
- If CurrentProject.AllReports(strReport).IsLoaded Then
- DoCmd.Close acReport, strReport
- End If
- Debug.Print strWhere
- DoCmd.OpenReport strReport, lngView, , strWhere
- Exit_Handler:
- Exit Sub
- Err_Handler:
- If Err.Number <> 2501 Then
- MsgBox "Error " & Err.Number & ": " & Err.Description, vbExclamation, "Cannot open report"
- End If
- Resume Exit_Handler
- End Sub