UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Question about the filter property...    
 
   
Accipiter22
post Nov 15 2006, 02:47 PM
Post #1

UtterAccess Guru
Posts: 537
From: Boston, MA



I have a form with subforms on it....now the main form has a field called AreaID, which can have values of 1, 2, or 3. I only want to see on this form those records that have an AreaID=1....I tried using the Filter property under data on the form properties...I typed "AreaID="1" and "AreaID=1" but neither worked...
Go to the top of the page
 
+
vtd
post Nov 15 2006, 03:49 PM
Post #2

Retired Moderator
Posts: 19,667



If you use the Form's Filter property in the DesignView of the Form, you need to set the FilterOn property to True by code in the Open or Load Event. Check Access VB Help on the FilterOn property.

There may be other difficulties using this method IIRC, e.g. the user may use a different Filter in the Form processing and this Filter string may replace the Filter string you set. Therefore, if you want to use this, you should always set the Filter and FilterOn properties by code. This way, you ensure that the the Filter string is correct when it is applied.

Personally, I prefer to use the selection in the RecordSource Query or the "wherecriteria" in the OpenForm statement which is used to open the Form.
Go to the top of the page
 
+
Accipiter22
post Nov 15 2006, 04:17 PM
Post #3

UtterAccess Guru
Posts: 537
From: Boston, MA



I tried using this in the On Load event:

Me.Filter = "AreaID= '1'"
Me.FilterOn = True

and it errors out.
Go to the top of the page
 
+
vtd
post Nov 15 2006, 08:07 PM
Post #4

Retired Moderator
Posts: 19,667



Is AreaID a numeric Field?

If it is, you need to use:

CODE
Me.Filter = "AreaID = 1"
Go to the top of the page
 
+
Accipiter22
post Nov 17 2006, 09:45 AM
Post #5

UtterAccess Guru
Posts: 537
From: Boston, MA



oh ok...it is a numeric field. thanks!
Go to the top of the page
 
+
vtd
post Nov 17 2006, 05:19 PM
Post #6

Retired Moderator
Posts: 19,667



You're welcome ... Gld to help ...
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 25th May 2013 - 10:07 AM