Steven.Ashby82
Registered User.
- Local time
- Today, 02:35
- Joined
- Jan 14, 2013
- Messages
- 63
Hi All
I need to run a report containing several rules.
I need to have all records with the field as "Open/Reopened" and "Pending" displayed in my report and the I want to select the date of which "Closed" records to display.
I currently have a form which allows me to search by date and Status but I need to achieve the above.
I need to run a report containing several rules.
I need to have all records with the field as "Open/Reopened" and "Pending" displayed in my report and the I want to select the date of which "Closed" records to display.
I currently have a form which allows me to search by date and Status but I need to achieve the above.
Code:
Private Sub genQuery_Click()
Dim strSQL As String
If Me.StatusCmbBox.ListIndex = -1 Then
Call MsgBox("You have to select a Status to run the Report !", vbInformation, "Missing Information")
Exit Sub
End If
If Len(Me.txtDateFrom & vbNullString) = 0 Then
Call MsgBox("You have to set a Start date to run the Report !", vbInformation, "Missing Information")
Exit Sub
End If
If Len(Me.txtDateUntil & vbNullString) = 0 Then
Call MsgBox("You have to set a End date to run the Report !", vbInformation, "Missing Information")
Exit Sub
End If
strSQL = "SELECT FaultTable.* FROM FaultTable WHERE ((Status = '" & StatusCmbBox & "') AND (DateRaised BETWEEN " & Format(txtDateFrom, "\#mm\/dd\/yyyy\#") & " AND " & Format(txtDateUntil, "\#mm\/dd\/yyyy\#") & "))"
DoCmd.OpenReport "Monthly Report", acViewReport, OpenArgs:=strSQL
Debug.Print strSQL
End Sub