mloucel
Member
- Local time
- Today, 08:48
- Joined
- Aug 5, 2020
- Messages
- 332
Hello All:
I have the following SQL:
I Did not create the SQL since I am NOT that advanced, credits to @arnelgp , @MajP and @theDBguy for their help in this one.
I need to ADD a new variable to this:
"Me.PendingChk=TRUE"
This is the Form:
So now if the User clicks ANY of those fields once the RecordSource is changed should work sorting by the required changes, could be any of them or All of them
Right now Dates and STAT work fine, no problem whatsoever. I just need to ADD Pending to the equation.
Any Help will be appreciated.
I have the following SQL:
Code:
Private Sub RefreshButton_Click()
'
' Code courtesy of @Arnelgp [AWF]
' Update courtesy of @MajP [AWF]
' Shout out to @theDBguy for his awesome knowledge [AWF]
'
Dim sql As String
Dim i As Integer
Dim Db As DAO.Database
If IsDate(Me.FromDate) And IsDate(Me.ToDate) Then
' change the record source of your form
Set Db = CurrentDb
sql = Db.QueryDefs("qryAuthorizationFullView").sql
'remove the ; at the end
sql = Replace$(sql, ";", "")
'check to see if there is a where clause
i = InStr(1, sql, "WHERE")
'Keep everything before the where close
If i <> 0 Then
sql = Left$(sql, i - 1)
End If
' was "ORDER By ReferDate"
'I am assuming both date boxes have to be in or it will not filter sometimes peope will do an after or before filter if only one date entered
'Stat true and both dates fille in
If Me.StatCheck = True And _
IsDate(Me.FromDate) And _
IsDate(Me.ToDate) Then
sql = sql & " WHERE ReferDate Between #" & Format$(Me.FromDate, "mm/dd/yyyy") & _
"# AND #" & Format$(Me.ToDate, "mm/dd/yyyy") & "#" & _
" OR AuthorizationT.Urgent = TRUE or AuthorizationT.Pending = TRUE ORDER By AuthorizationT.Urgent, AuthorizationT.AuthorizationID"
'Stat true but one of the dates not filled in
ElseIf Me.StatCheck = True And Not IsDate(Me.FromDate) Or Not IsDate(Me.ToDate) Then
sql = sql & " WHERE StatCheck = TRUE Order by AuthorizationT.AuthorizationID"
'Stat false and both dates filled in
ElseIf Me.StatCheck = False And IsDate(Me.FromDate) And IsDate(Me.ToDate) Then
sql = sql & " WHERE ReferDate Between #" & Format$(Me.FromDate, "mm/dd/yyyy") & _
"# AND #" & Format$(Me.ToDate, "mm/dd/yyyy") & "#" & _
"ORDER By AuthorizationT.AuthorizationID"
End If
RecordSource = sql
End If
Set Db = Nothing
End Sub
I Did not create the SQL since I am NOT that advanced, credits to @arnelgp , @MajP and @theDBguy for their help in this one.
I need to ADD a new variable to this:
"Me.PendingChk=TRUE"
This is the Form:
So now if the User clicks ANY of those fields once the RecordSource is changed should work sorting by the required changes, could be any of them or All of them
Right now Dates and STAT work fine, no problem whatsoever. I just need to ADD Pending to the equation.
Any Help will be appreciated.