• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

Removing filters on a form when they open

I have a form that according to my code, checks to see if there are any items needed to be passed in the Me.OpenArgs argument.  If there is nothing to be passed, then it should be a new record.  Unfortunately, my program does not work as planned.  I get an error of the following:

Run-time error: '30010':
Cannot apply filter on one or more fields specified in the Filter property.

Below is the sub of code that I have used for this open event:

Private Sub Form_Open(Cancel As Integer)

     If Me.OpenArgs = Null Or Me.OpenArgs = "" Or Me.OpenArgs = " " Then
        'new project
        DoCmd.GoToRecord acActiveDataObject, , acNewRec
    Else
   
    Me.Filter = "ProjectID = " & Me.OpenArgs
    Me.FilterOn = True
   
    End If
   
End Sub
0
VBBRett
Asked:
VBBRett
  • 3
  • 2
1 Solution
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
If Nz(Me.OpenArgs, "") = "" then
   Me.Filter = ""
   Me.FilterOn = False

  'new project
   DoCmd.GoToRecord acActiveDataObject, , acNewRec
else
  Me.Filter = "ProjectID = " & Me.OpenArgs
   Me.FilterOn = True
end if
0
 
VBBRettAuthor Commented:
Thanks Jimhorn!  You've been a great big help!
0
 
VBBRettAuthor Commented:
What does nz stand for in the expression  Ifnz(me.openargs,"")="" then
                                                                      Me.Filter = ""
                                                                      Me.FilterOn = False
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
The Nz(value, value if null) function returns value if it is not null, or 'value if null' if it is null.  It is real damn-handy.

Nz(7, 0) = 7
Nz(NULL, 0) = 0

0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Thanks for the grade.  Good luck with your project.  -Jim
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now