G
Guest
Hi All,
I have constructed the following code based on some examples that I have
seen on several threads. However, I am problems running the code.
I keep getting the error "You can't assign a value to this object" and the
debugger highlights the line
Me.Filter = mstrFormFilter
Can anyone tell me why I am getting the error?
Here's the whole thing:
Dim mstrSpecFilter As String
Dim mstrCnt_NumFilter As String
Dim mstrAcct_NmFilter As String
Dim mstrAcct_NumFilter As String
Dim mstrExp_Mo_YrFilter As String
Dim mstrTerrFilter As String
Dim mstrFormFilter As String
Dim mstrActnFilter As String
Private Function BuildFilter() As Variant
If Len(mstrExp_Mo_YrFilter) = 0 Then mstrExp_Mo_YrFilter = "Like *"
If Len(mstrSpecFilter) = 0 Then mstrSpecFilter = "Like *"
If Len(mstrTerrFilter) = 0 Then mstrTerrFilter = "Like *"
If Len(mstrAcct_NmFilter) = 0 Then mstrAcct_NmFilter = "Like *"
If Len(mstrAcct_NumFilter) = 0 Then mstrAcct_NumFilter = "Like *"
If Len(mstrCnt_NumFilter) = 0 Then mstrCnt_NumFilter = "Like *"
If Len(mstrActnFilter) = 0 Then mstrActnFilter = "Like*"
mstrFormFilter = "[Cnt_Spec] " & mstrSpecFilter & "' AND [Terr] " &
mstrTerrFilter & "' AND [Acct_Name] & mstrAcct_NmFilter & " ' AND
[Account_No] " & mstrAcct_NumFilter & "' AND [Month/Year] " &
mstrExp_Mo_YrFilter & '" AND [Contract_No]" & mstrCnt_NumFilter & "' AND
[Action]" & mstrActnFilter & "'"
Me.Filter = mstrFormFilter
Me.FilterOn = True
Me.Requery
End Function
Private Sub cbo_Month_Year_AfterUpdate()
mstrExp_Mo_YrFilter = "='" & cbo_Month_Year & "'"
Call BuildFilter
End Sub
Private Sub cbo_Cnt_Spec_AfterUpdate()
mstrSpecFilter = "='" & cbo_Cnt_Spec & "'"
Call BuildFilter
End Sub
Private Sub cbo_Terr_AfterUpdate()
mstrTerrFilter = "=" & cbo_Terr & "'"
Call BuildFilter
End Sub
Private Sub cbo_Account_No_AfterUpdate()
mstrAcct_NumFilter = "='" & cbo_account_No & "'"
Call BuildFilter
End Sub
Private Sub cbo_Action_AfterUpdate()
mstrActnFilter = "='" & cbo_Action & "'"
Call BuildFilter
End Sub
Private Sub cbo_Contract_No_AfterUpdate()
mstrCnt_NumFilter = "='" & cbo_contract_No & "'"
Call BuildFilter
End Sub
Private Sub cob_Acct_Name_AfterUpdate()
mstrAcct_NmFilter = "='" & cbo_Acct_Name & "'"
Call BuildFilter
End Sub
Thank you,
I have constructed the following code based on some examples that I have
seen on several threads. However, I am problems running the code.
I keep getting the error "You can't assign a value to this object" and the
debugger highlights the line
Me.Filter = mstrFormFilter
Can anyone tell me why I am getting the error?
Here's the whole thing:
Dim mstrSpecFilter As String
Dim mstrCnt_NumFilter As String
Dim mstrAcct_NmFilter As String
Dim mstrAcct_NumFilter As String
Dim mstrExp_Mo_YrFilter As String
Dim mstrTerrFilter As String
Dim mstrFormFilter As String
Dim mstrActnFilter As String
Private Function BuildFilter() As Variant
If Len(mstrExp_Mo_YrFilter) = 0 Then mstrExp_Mo_YrFilter = "Like *"
If Len(mstrSpecFilter) = 0 Then mstrSpecFilter = "Like *"
If Len(mstrTerrFilter) = 0 Then mstrTerrFilter = "Like *"
If Len(mstrAcct_NmFilter) = 0 Then mstrAcct_NmFilter = "Like *"
If Len(mstrAcct_NumFilter) = 0 Then mstrAcct_NumFilter = "Like *"
If Len(mstrCnt_NumFilter) = 0 Then mstrCnt_NumFilter = "Like *"
If Len(mstrActnFilter) = 0 Then mstrActnFilter = "Like*"
mstrFormFilter = "[Cnt_Spec] " & mstrSpecFilter & "' AND [Terr] " &
mstrTerrFilter & "' AND [Acct_Name] & mstrAcct_NmFilter & " ' AND
[Account_No] " & mstrAcct_NumFilter & "' AND [Month/Year] " &
mstrExp_Mo_YrFilter & '" AND [Contract_No]" & mstrCnt_NumFilter & "' AND
[Action]" & mstrActnFilter & "'"
Me.Filter = mstrFormFilter
Me.FilterOn = True
Me.Requery
End Function
Private Sub cbo_Month_Year_AfterUpdate()
mstrExp_Mo_YrFilter = "='" & cbo_Month_Year & "'"
Call BuildFilter
End Sub
Private Sub cbo_Cnt_Spec_AfterUpdate()
mstrSpecFilter = "='" & cbo_Cnt_Spec & "'"
Call BuildFilter
End Sub
Private Sub cbo_Terr_AfterUpdate()
mstrTerrFilter = "=" & cbo_Terr & "'"
Call BuildFilter
End Sub
Private Sub cbo_Account_No_AfterUpdate()
mstrAcct_NumFilter = "='" & cbo_account_No & "'"
Call BuildFilter
End Sub
Private Sub cbo_Action_AfterUpdate()
mstrActnFilter = "='" & cbo_Action & "'"
Call BuildFilter
End Sub
Private Sub cbo_Contract_No_AfterUpdate()
mstrCnt_NumFilter = "='" & cbo_contract_No & "'"
Call BuildFilter
End Sub
Private Sub cob_Acct_Name_AfterUpdate()
mstrAcct_NmFilter = "='" & cbo_Acct_Name & "'"
Call BuildFilter
End Sub
Thank you,