J
jshangkuan
I'm trying to create a search box by applying a filter. Say for
example I have a table that has holds the part number and other
information. I created a box to enter the part number. When the
search button is clicked it executes the below vba code. However, when
it runs through a message box that says "Enter MyTable.Part Number
value" and gives a box to enter a value. I think that this only
happens if the column doesn't exist. Why does this happen? What can I
do to fix this? This should be very simple and filter based on the
exact text I enter.
thanks for your help
Private Sub searchParam_Click()
Dim strWhere AS String
strWhere = "1=1"
If Nz(Me.box1) <> "" Then
strWhere = strWhere & " AND " & "MyTable.[Part Number] = '" &
Me.box1 & "'"
End If
Me.mySubform.Form.Filter = strWhere
Me.mySubform.Form.FilterOn = True
end sub
example I have a table that has holds the part number and other
information. I created a box to enter the part number. When the
search button is clicked it executes the below vba code. However, when
it runs through a message box that says "Enter MyTable.Part Number
value" and gives a box to enter a value. I think that this only
happens if the column doesn't exist. Why does this happen? What can I
do to fix this? This should be very simple and filter based on the
exact text I enter.
thanks for your help
Private Sub searchParam_Click()
Dim strWhere AS String
strWhere = "1=1"
If Nz(Me.box1) <> "" Then
strWhere = strWhere & " AND " & "MyTable.[Part Number] = '" &
Me.box1 & "'"
End If
Me.mySubform.Form.Filter = strWhere
Me.mySubform.Form.FilterOn = True
end sub