mloucel
Member
- Local time
- Today, 10:50
- Joined
- Aug 5, 2020
- Messages
- 313
I have the following button that refreshes my form IF the EU changes the dates, so far it was ok, until my boss decided to change a bit:
Now She wants to ADD a field we call [STAT] is a CHECK BOX, I need to add this to the equation:
In my vision when the user use the check mark I want to see the STAT orders first, REGARDLESS of the dates, this is important because it is more important STAT than the dates but since those dates are already there.
This is how it looks [TEST DATA ONLY NOT REAL]
when the EU clicks STAT both RED should be at the top, there are more records not shown here, the whole purpose is to show ALL those STAT records first, if the user UN-CHECK STAT just simply SORT by DATES ignoring [STAT] check mark completely.
CORRECTION: The SORT WILL work ONLY when Checked [TRUE] when is FALSE should be IGNORED completely in the equation.
This is the code I have so far:
Now She wants to ADD a field we call [STAT] is a CHECK BOX, I need to add this to the equation:
In my vision when the user use the check mark I want to see the STAT orders first, REGARDLESS of the dates, this is important because it is more important STAT than the dates but since those dates are already there.
This is how it looks [TEST DATA ONLY NOT REAL]
when the EU clicks STAT both RED should be at the top, there are more records not shown here, the whole purpose is to show ALL those STAT records first, if the user UN-CHECK STAT just simply SORT by DATES ignoring [STAT] check mark completely.
CORRECTION: The SORT WILL work ONLY when Checked [TRUE] when is FALSE should be IGNORED completely in the equation.
This is the code I have so far:
Code:
Private Sub RefreshButton_Click()
'
' Code courtesy of @Arnelgp
'
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
sql = Replace$(sql, ";", "")
i = InStr(1, sql, "WHERE")
If i <> 0 Then
sql = Left$(sql, i - 1)
End If
' was "ORDER By ReferDate"
sql = sql & " WHERE ReferDate Between #" & Format$(Me.FromDate, "mm/dd/yyyy") & _
"# AND #" & Format$(Me.ToDate, "mm/dd/yyyy") & "#" & "ORDER By AuthorizationT.AuthorizationID"
RecordSource = sql
End If
Set Db = Nothing
End Sub