Problem filtering subform

NachoMan

Registered User.
Local time
Today, 02:14
Joined
Sep 28, 2003
Messages
56
Friends,
I'm having an odd problem with my Contacts Addressbook form. I have a addressbook-style form that lists several buttons along the bottom (i.e A-z, "ALL") that are used to filter names matching the selected letter criteria. The same set up is used in the Northwind Sample DB. The form works fine when its opened by itself, but my database is set up where all forms are opened in a window (subform) on my switchboard. The addressbook opens up fine in the switchboard subform, but when I go to filter the recordset by clicking one of the letter buttons, I get the error "The action or method is invalid because the form or report isn't bound to a table or a query." This doesn't make sense to me since the form is, in fact, based on a query.

Any ideas why the thing works as a stand-alone form, but not when opened in a subform? Any help, hints would be greatly appreciated.

-Lou
 
Did you import the macro named " Alpha Buttons" in your Db ?

Le
 
Yes. As I mentioned, the form works fine if its opened up by itself. It fails to work only when I open it through the subform in my switchboard. I figure it has something to do with the way the ApplyFilter action works. It seems that it may be trying to apply the filter to the parent form (Switchboard) maybe. Any ideas?
:confused:
- Lou
 
Well, I don't know this is the best way but try this, it works.

Instead of using a Macro change for an option filter. Go to the event after Update, delete the macro and put this code :

Code:
Private Sub CompanyNameFilters_AfterUpdate()
     
     Select Case Me.CompanyNameFilters                  
            
        Case Is = 1
            Me.Form.Filter = "CompanyName like ""[AÀÁÂÃÄ]*"""
            Me.Form.FilterOn = True
         
        '...
        
        Case Is = 27
            DoCmd.ShowAllRecords
    
    End Select
End Sub

Le
 
Tried that already.

Yeah, I thought that maybe if I just convert the macro and use the VBA, but negative. Same exact result, error message. I am pretty sure that it has something to do with the ApplyFilter action. I'm thinking that it automatically tries to filter the active form. Since, in my case, the unbound switchboard is the active form, the code fails. I have to somehow make sure that the filter is applied to the form embedded in the Switchboard window. I could be wrong, but that's what I'm thinking at this point. Thanks for the replies. Any other ideas are welcome and appreciated.

-Lou
 
hmm

le888,
Okay, now I'm confused. I had the exact set up as you (converted Alpha buttons macro to vba), but I continued to get the error msg that says my form is not based on a table or query. I must have overlooked something, or the cause of my problem is altogether different from what I was thinking. I'll check it out again when I get back to the office tomorrow. Thanks again for your efforts and time in helping me out. I'll let you know what the problem was. Thanks. Take it slow.

-Lou
 
Got it.

No, I suppose I didn't have things exactly the same way afterall. For starters, I didn't even have the "FilterOn" line in there. With your example, I got it rolling. Thanks a lot. Take it slow.

-Lou
 
thx :] i`ve used Your code.. I wanted to make Filter on data field with help of Input box, but just modified Your code and it works with one button :]

Code:
Private Sub Polecenie27_Click()

If Form.FilterOn = False Then
            Me.Form.Filter = "DATA Like [The Date]"
            Me.Form.FilterOn = True
            Polecenie27.Caption = "Remove filter"
            Else
                Form.FilterOn = False
                Polecenie27.Caption = "Filter"
End If

End Sub
 

Users who are viewing this thread

Back
Top Bottom