Form, SubForm` Apply Filter problem

D

Deb Smith

I am having a problem getting a subform's filter to work properly.

I have a from called "Phone" and a subform called "Phonesub". On the subform
I have an option group called LastNameFilters that contains alpha buttons.
As a subform everything works great. As expected, when an alpha button is
clicked, only those records related to that letter are shown. The problem is
when the subform is inserted on the main form, the option group (filter no
longer works). All records are displayed, however, when an alpha button is
pressed the records for the individual letters are not displayed. Only those
records related to A.

The code behind this option group is as follows

If (LastNameFilters = 1) Then
' Filter for Last names names that start with A, À, Á, Â, Ã, or Ä.
DoCmd.ApplyFilter "", "[LastName] Like ""[AÀÁÂÃÄ]*"""
End If
Etc to 27 where
If (LastNameFilters = 27) Then
DoCmd.ShowAllRecords
End If

If (RecordsetClone.RecordCount > 0) Then
DoCmd.GoToControl "LastName"
DoCmd.GoToControl "LastName"
Exit Sub

End If
If (RecordsetClone.RecordCount = 0) Then
MsgBox "There are no records for that letter.", vbInformation, "No Records
Returned"
DoCmd.ShowAllRecords
LastNameFilters = 27
End If

What am I doing wrong? Why does it work as a standalone form but as a
subform not perform as expected. Suggestions would be greatly appreciated.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top