G
Guest
Hello all,
I'm hoping someone can help. I'm trying to execute a filter on a form that
utilizes a subform. I also have a combo box on the form, which when the
filter is applied, works. I just can't get the subform part to work. I
receive the error: "Is not a valid name. Make sure it does not include
invalid characters or punctuation and that it is not too long.
Here is the code:
Private Sub cmdFilter_Click()
Dim strWhere As String
Dim lngLen As Long
If Not IsNull(Me.suppliercmbo) Then
strWhere = strWhere & "([Supplier] Like ""*" & Me.suppliercmbo &
"*"") AND "
End If
If Not IsNull(Me.Productnamecmbo) Then
strWhere = strWhere & "([Me.frm_product_sub.Form!Product Name] Like
""*" & Me.Productnamecmbo & "*"") AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
Else
strWhere = Left(strWhere, lngLen)
Me.filter = strWhere
Me.FilterOn = True
End If
End Sub
Here are the specifics:
Main form name = frm_inputform
Subform name = frm_product_sub
Subform Control Source = Product Name
Name of Combo Box on subform = productcmbo
Name of Combo Box on main form = productnamecmbo
I'm hoping someone can help. I'm trying to execute a filter on a form that
utilizes a subform. I also have a combo box on the form, which when the
filter is applied, works. I just can't get the subform part to work. I
receive the error: "Is not a valid name. Make sure it does not include
invalid characters or punctuation and that it is not too long.
Here is the code:
Private Sub cmdFilter_Click()
Dim strWhere As String
Dim lngLen As Long
If Not IsNull(Me.suppliercmbo) Then
strWhere = strWhere & "([Supplier] Like ""*" & Me.suppliercmbo &
"*"") AND "
End If
If Not IsNull(Me.Productnamecmbo) Then
strWhere = strWhere & "([Me.frm_product_sub.Form!Product Name] Like
""*" & Me.Productnamecmbo & "*"") AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
Else
strWhere = Left(strWhere, lngLen)
Me.filter = strWhere
Me.FilterOn = True
End If
End Sub
Here are the specifics:
Main form name = frm_inputform
Subform name = frm_product_sub
Subform Control Source = Product Name
Name of Combo Box on subform = productcmbo
Name of Combo Box on main form = productnamecmbo