The action or method is invalid because the form or report isn't bound to a table or

ddcessex

Registered User.
Local time
Today, 16:00
Joined
Jan 14, 2016
Messages
23
I setup a blank, unbound Main Form and created a Sub Form into which I pasted a previously created datasheet view form.

This works fine

On the the Main form I put some command buttons that, when clicked, call procedure that is written in the Main Form's Module.

This is where the problem starts as the click event on the button generates the following error:

"The action or method is invalid because the form or report isn't bound to a table or query"

Here is the function:


Database
Option Explicit

Private Function ApplyTheFilter() As String
Dim strAlpha As String
Dim strField As String

strAlpha = Forms!dsvMainSubContacts.ActiveControl.Tag
strField = Forms!dsvMainSubContacts!txtSearch.Tag
If (strAlpha > "") And (strField > "") Then
Select Case strAlpha
Case "All"
DoCmd.ApplyFilter "Temp", "Company LIKE '*'", ""
Case Else
DoCmd.ApplyFilter "Temp", strField & " LIKE '" & strAlpha & "*'", ""
End Select
ElseIf (strAlpha > "") Then
Select Case strAlpha
Case "All"
DoCmd.ApplyFilter "Temp", "Company LIKE '*'", ""
Case Else
DoCmd.ApplyFilter "Temp", "Company LIKE '" & strAlpha & "*'", ""
End Select
End If
End Function


ps. This is driving me nuts - I have tried to research this for a couple of days now and wouldn't post this query unless as a last resort.

:banghead::mad:
 
I don't believe DoCmd.ApplyFilter works with a subform. In place of those you need something like:

Code:
Me.YourSubFormName.Form.Filter =  "Company LIKE '*'", ""
Me.YourSubFormName.Form.FilterOn = True
 
I don't believe DoCmd.ApplyFilter works with a subform. In place of those you need something like:

Code:
Me.YourSubFormName.Form.Filter =  "Company LIKE '*'", ""
Me.YourSubFormName.Form.FilterOn = True

OMG It worked!

Thank you so much.

Can I include an ORDER BY argument in .Filter?
 
That a different property called Order by so add something like.

Code:
Me.YourSubFormName.Form.OrderBy =  "Company"

I think before you do the filter thing.
 
That a different property called Order by so add something like.

Code:
Me.YourSubFormName.Form.OrderBy =  "Company"

I think before you do the filter thing.

You made my day!

Thank you so much!
 

Users who are viewing this thread

Back
Top Bottom