?
Solved

Removing filters on a form when they open

Posted on 2007-10-15
5
Medium Priority
?
262 Views
Last Modified: 2013-11-28
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
Comment
Question by:VBBRett
  • 3
  • 2
5 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 total points
ID: 20081513
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
 

Author Comment

by:VBBRett
ID: 20081577
Thanks Jimhorn!  You've been a great big help!
0
 

Author Comment

by:VBBRett
ID: 20081586
What does nz stand for in the expression  Ifnz(me.openargs,"")="" then
                                                                      Me.Filter = ""
                                                                      Me.FilterOn = False
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 20081596
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
 
LVL 66

Expert Comment

by:Jim Horn
ID: 20085668
Thanks for the grade.  Good luck with your project.  -Jim
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question