I am not very good with VBA but I will try to get all the details in here. I am trying to use 5 combo boxes and 2 text boxes to look up and generate a report based off of those selections. I want it to generate a report as well once I click on the command button. I have the 2 text boxes setup as from and to date boxes that I pulled off of another site. I included attachments to try to clarify this a little bit.
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.
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.
Code:
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
Comment