Open a form without applying the filter

TAM

Board Regular
Joined
Oct 10, 2008
Messages
114
I have a main navigation from which I select a number of forms to open with the use of a button.

The form I added a form which is a continuous form has a filter which allows the user to enter data. The search filter is: [Practice_Name] Like "*" & [Forms]![Frm_TeamEnrollment]![Search_Team] & "*" Or [Rep] Like "*" & [Forms]![Frm_TeamEnrollment]![Search_Team] & "*" Or [practice_id] Like "*" & [Forms]![Frm_TeamEnrollment]![Search_Team]

The filter works great. My challenge is when I open the database. I get the error message "2491" for the argument "Fltr_SearchTeam, ,". "The action or method is invalid because the form or report isn't bound to a table or query."

The form is bound to a table.

What is the VB code I should use to open the form and eliminate this error?

Thanks!!
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Not clear what you are doing. First it sounds like you are opening all forms from your main form (switchboard) and have assigned the expression to the filter property of one of those forms. In that case, generating the error message because you opened the database makes no sense. In spite of that, I can make a suggestion based on your question.

Try using the openArgs property. This is sometimes done to open the same form in multiple modes or with various filters, for example. The syntax is DoCmd.OpenForm FormName, View, FilterName, WhereCondition, DataMode, WindowMode, OpenArgs. So you might use Docmd.OpenForm "frmName",,,,,,"NoFilter".

In the form OpenEvent, you check for the argument and execute code accordingly. E.g. (asuming only 1 or 2 possibilities)

Code:
Private Sub Form_Open(Cancel As Integer)
Dim strFilter as String
If Me.OpenArgs = "NoFilter" then 
  With Me
    .Filter = ""
    .FilterOn = False
  End With
End If
If Me.OpenArgs = "Filter1" then 
  strFilter = "[Practice_Name] Like '*' &  [Forms]![Frm_TeamEnrollment]![Search_Team] & '*' Or "
  strFilter= strFilter& "[Rep] Like '*'  & [Forms]![Frm_TeamEnrollment]![Search_Team] & '*' Or  "
  strFilter= strFilter& "[practice_id] Like '*' & [Forms]![Frm_TeamEnrollment]![Search_Team]"
  With Me
    .Filter = strFilter
    .FilterOn = True
  End With
End If
You could also pass a filter string to the FilterName property of the form open code; I prefer the above method because I can control other form properties based on the openArgs. However, your filter looks more like a recordsource sql for a form, so maybe you ought to be setting the form's recordsource based on the openArgs instead.
 
Upvote 0
You're welcome. Hope you have the time to share what your solution was (passing the filter; creating the filter in the open event; setting the recordsource in the open event...)
 
Upvote 0

Forum statistics

Threads
1,221,832
Messages
6,162,254
Members
451,757
Latest member
iours

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top