PC User
Registered User.
- Local time
- Today, 06:36
- Joined
- Jul 28, 2002
- Messages
- 193
On my form I have several filters that work independently; however, in order to maintain a display of data that I want, these filters need to be combined. Can someone help me build a complete form filter by using these individual filters?
Form Declarations
Sort Rows
Expand or Compress Rows by using two different subforms giving the appearance of expanding and compressing.
Select an account name from a combobox list of accounts.
Select a range of dates to display the account transactions.
Thanks,
PC
Form Declarations
Code:
Option Compare Database
Option Explicit
Dim strSelect As String, strFrom As String
Dim strSQL As String, strWhere As String
Dim strOrderBy As String
Code:
Private Sub optRowSort_AfterUpdate()
strSelect = "SELECT q2subJournal.* "
strFrom = "FROM q2subJournal "
Select Case optRowSort
Case 1
strOrderBy = "ORDER BY " & "TickerId" & " Desc"
Case 2
strOrderBy = "ORDER BY " & "TickerId" & " Asc"
End Select
strSQL = strSelect & strFrom & strOrderBy
Me!ctlsubForm.Form.RecordSource = strSQL
Me!ctlsubForm.Form.Requery
End Sub
Code:
Private Sub optRowStatus_AfterUpdate()
Select Case optRowStatus
Case 1
Me!ctlsubForm.SourceObject = "f2subExpandedRows"
Case 2
Me!ctlsubForm.SourceObject = "f2subCompressedRows"
End Select
End Sub
Code:
Private Sub cboAccount_AfterUpdate()
If IsNull(Me.cboAccount) Then
strSelect = "SELECT q2subJournal.* "
strFrom = "FROM q2subJournal "
strWhere = " "
strSQL = strSelect & strFrom & strWhere
Me!ctlsubForm.Form.RecordSource = strSQL
Me!ctlsubForm.Form.Requery
Else
strSelect = "SELECT q2subJournal.* "
strFrom = "FROM q2subJournal "
strWhere = "WHERE q2subJournal.AccountId = " & Me.cboAccount.Column(0)
strSQL = strSelect & strFrom & strWhere
Me!ctlsubForm.Form.RecordSource = strSQL
Me!ctlsubForm.Form.Requery
End If
End Sub
Code:
Private Sub cboDateRange_AfterUpdate()
strSelect = "SELECT q2subJournal.* "
strFrom = "FROM q2subJournal "
If Me.cboDateRange <> "" Then
If Me.cboDateRange = "Last 30 Days" Then
strWhere = "WHERE q2subJournal.EnterDate " & "Between " & "#" & Format(DateAdd("d", -30, Now()), "Short Date") & "#" & " And " & "#" & Format(Now(), "Short Date") & "#"
Else
If Me.cboDateRange = "Last 1 Year" Then
strWhere = "WHERE q2subJournal.EnterDate " & "Between " & "#" & Format(DateAdd("y", -1, Now()), "Short Date") & "#" & " And " & "#" & Format(Now(), "Short Date") & "#"
Else
If Me.cboDateRange = "Annual Period" Then
strWhere = "WHERE q2subJournal.EnterDate " & "Between " & "#" & Format(DateAdd("y", -1, Now()), "Short Date") & "#" & " And " & "#" & Format(Now(), "Short Date") & "#"
Else
If Me.cboDateRange = "Date Range" Then
DoCmd.OpenForm "fpopSelectDateRange"
End If
End If
End If
End If
End If
strSQL = strSelect & strFrom & strWhere
Me!ctlsubForm.Form.RecordSource = strSQL
Me!ctlsubForm.Form.Requery
End Sub
PC