G
Guest
Hi All,
I am running the following code and getting the "You Cancelled the previous
operation" error message. When I first open the form the error shows up on
the "Me.Filter = Left(strFilter, Len(strFilter) - Len(cAND))" line but then
on subsequent attempts it shows up on the "Me.FilterOn = True" line.
On the Main form "cbo_cnt_spec" and on the subform "Cnt_spec" are both
Lookup fields where I am trying to match the second colum. The same applies
to the Main form "cbo_actn" and the subform "Action" fields. The first colum
is the number field, and the second column contains the text. Can I even do
that?
Here is some additional information:
Numeric fields on the main form are:
cbo_Acct_Num
cbo_Terr
and on the Subform the numeric fields are:
Account_No
Terr
Private Function BuildFilter()
Const cAND As String = " AND "
Dim strFilter As String
If Not IsNull(cbo_Cnt_Spec) Then
strFilter = strFilter & "[Cnt_Spec]='" & [cbo_Cnt_Spec].Column(1) & "'"
& cAND
End If
If Not IsNull(cbo_Terr) Then
strFilter = strFilter & "[Terr]=" & [cbo_Terr] & cAND
End If
If Not IsNull(cbo_account_No) Then
strFilter = strFilter & "[Acct_Num]=" & [cbo_account_No] & cAND
End If
If Not IsNull(cbo_Acct_Name) Then
strFilter = strFilter & "[Acct_Name]='" & [cbo_Acct_Name] & "'" & cAND
End If
If Not IsNull(cbo_contract_No) Then
strFilter = strFilter & "[Contract_No]='" & [cbo_contract_No] & "'" & cAND
End If
If Not IsNull(cbo_Month_Year) Then
strFilter = strFilter & "[Month/Year]='" & [cbo_Month_Year] & "'" & cAND
End If
If Not IsNull(cbo_actn_No) Then
strFilter = strFilter & "[Action]='" & [cbo_Action] & "'" & cAND
End If
If Len(strFilter) = 0 Then
Me.FilterOn = False
Else
' remove the last " AND "
Me.Filter = Left(strFilter, Len(strFilter) - Len(cAND))
Me.FilterOn = True
End If
End Function
I am running the following code and getting the "You Cancelled the previous
operation" error message. When I first open the form the error shows up on
the "Me.Filter = Left(strFilter, Len(strFilter) - Len(cAND))" line but then
on subsequent attempts it shows up on the "Me.FilterOn = True" line.
On the Main form "cbo_cnt_spec" and on the subform "Cnt_spec" are both
Lookup fields where I am trying to match the second colum. The same applies
to the Main form "cbo_actn" and the subform "Action" fields. The first colum
is the number field, and the second column contains the text. Can I even do
that?
Here is some additional information:
Numeric fields on the main form are:
cbo_Acct_Num
cbo_Terr
and on the Subform the numeric fields are:
Account_No
Terr
Private Function BuildFilter()
Const cAND As String = " AND "
Dim strFilter As String
If Not IsNull(cbo_Cnt_Spec) Then
strFilter = strFilter & "[Cnt_Spec]='" & [cbo_Cnt_Spec].Column(1) & "'"
& cAND
End If
If Not IsNull(cbo_Terr) Then
strFilter = strFilter & "[Terr]=" & [cbo_Terr] & cAND
End If
If Not IsNull(cbo_account_No) Then
strFilter = strFilter & "[Acct_Num]=" & [cbo_account_No] & cAND
End If
If Not IsNull(cbo_Acct_Name) Then
strFilter = strFilter & "[Acct_Name]='" & [cbo_Acct_Name] & "'" & cAND
End If
If Not IsNull(cbo_contract_No) Then
strFilter = strFilter & "[Contract_No]='" & [cbo_contract_No] & "'" & cAND
End If
If Not IsNull(cbo_Month_Year) Then
strFilter = strFilter & "[Month/Year]='" & [cbo_Month_Year] & "'" & cAND
End If
If Not IsNull(cbo_actn_No) Then
strFilter = strFilter & "[Action]='" & [cbo_Action] & "'" & cAND
End If
If Len(strFilter) = 0 Then
Me.FilterOn = False
Else
' remove the last " AND "
Me.Filter = Left(strFilter, Len(strFilter) - Len(cAND))
Me.FilterOn = True
End If
End Function