Thank you so much for your response. I'm an Access newbie so you'll
have to pardon if I make a statement or ask a question that would
cause a real Access user to shake their head, so you may have to walk
me through this like a toddler. My subform's name is book_subform and
the subform doesn't actually "appear" on the search form -- the form
is nothing more than 6 blanks for users to enter search terms. I
don't know what else to do but paste my form/subform info and the
code. Any time/help you can continue to offer is extremely
appreciated.
Form: Book_Search
Record source: qry_book_lookup
Subform: book_subform
Record source: qry_book_lookup
*********************************************
Private Sub Search_Results_Click()
On Error GoTo Err_Search_Results_Click
Dim strWhere As String
Dim lngLen As Long
'Author field
If Not IsNull(Me.authorselection) Then
strWhere = strWhere & "([author] Like ""*" & Me.authorselection
& "*"") AND "
End If
'Title Field
If Not IsNull(Me.Titleselection) Then
strWhere = strWhere & "([title] Like ""*" & Me.Titleselection
& "*"") AND "
End If
'Publisher field
If Not IsNull(Me.publisherselection) Then
strWhere = strWhere & "([publisher] Like ""*" &
Me.publisherselection & "*"") AND "
End If
'Abstract field
If Not IsNull(Me.abstractselection) Then
strWhere = strWhere & "([abstract] Like ""*" &
Me.abstractselection & "*"") AND "
End If
'Publication date field
If Not IsNull(Me.Pubdateselection) Then
strWhere = strWhere & "([PubDate] Like ""*" &
Me.Pubdateselection & "*"") AND "
End If
'Descriptor field
If Not IsNull(Me.descriptorsselection) Then 'Less than the next
day.
strWhere = strWhere & "([descriptors] Like ""*" &
Me.descriptorsselection & "*"") AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
Cancel = True
MsgBox "In order to perform a search, you must enter values in
one or more search fields.", vbInformation, "No Criteria Entered"
Else
strWhere = Left$(strWhere, lngLen)
'For debugging, remove the leading quote on the next line.
Prints to Immediate Window (Ctrl+G).
'Debug.Print strWhere
'Apply the string as the form's Filter.
'This is where I am getting hung up on everyone else's
computer.
Me.book_subform.Form.Filter = strWhere
Me.book_subform.Form.FilterOn = True
'Me.Filter = strWhere
'Me.FilterOn = True
'DoCmd.OpenForm "book_subform"
DoCmd.ApplyFilter "book_subform", Me.Filter
End If
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 2, , acMenuVer70
Exit_Search_Results_Click:
Exit Sub
Err_Search_Results_Click:
MsgBox Err.Description
Resume Exit_Search_Results_Click
End Sub
**************************************************
Clears the search criteria from the form
Private Sub Clear_Form_Click()
On Error GoTo Err_Clear_Form_Click
'Me.FilterOn = False
Me.book_subform.Form.FilterOn = False
Me.authorselection.Value = Null
Me.Titleselection.Value = Null
Me.publisherselection.Value = Null
Me.PubDate.Value = Null
Me.abstractselection.Value = Null
Me.descriptorsselection.Value = Null
Me.searchallselection.Value = Null
Exit_Clear_Form_Click:
Exit Sub
Err_Clear_Form_Click:
MsgBox Err.Description
Resume Exit_Clear_Form_Click
End Sub
check your naming. This is an issue that often confused.
In this syntax:
Me.book_subform.Form.Filter > = strWhereSearch
book_subform is the name of the subform control on the main form, not the
name of the form being used as the subform. That is where the confusion
lies. On your main form, you have a subform control. One of its properties
is Source Object. The Source Object property contains the name of the form
that shows in the subform control.
You do not refer to the name of the form being used as the subform. That is
handled by the Form object. so the syntax is
Me.SubformControlName.Form.
--
Dave Hargis, Microsoft Access MVP
- Show quoted text -