[AccessD] trying to filter a form on a control's value

Bill Benson bensonforums at gmail.com
Thu Dec 25 17:21:53 CST 2014


But that is not any better than using the UDF Jim (well, a tiny bit less
overhead and a bit more direct). However, when the control changes there
will be no change to what the filter evaluates to when the control changes
value. And that is my goal.


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Jim Dettman
Sent: Thursday, December 25, 2014 6:18 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] trying to filter a form on a control's value


 You were close....correct syntax is:

 Me.Filter = "[FKCompanyID] = " & [Forms]!frmOrders![txtWholesalerID]

  if this is frmOrders, then that can be shortened to:

 Me.Filter = "[FKCompanyID] = " & Me.[txtWholesalerID]

 This assumes a numeric.  If ID is text, then:

 Me.Filter = "[FKCompanyID] = " & chr$(34) &
[Forms]!frmOrders![txtWholesalerID] & chr$(34)

Jim.

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Bill Benson
Sent: Thursday, December 25, 2014 05:50 PM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] trying to filter a form on a control's value

I want to filter a form, when a toggle is depressed based on a control value
on my form. When that control changes, I want the filter to be applied. I
have tried without success to set the filter a myriad of different ways, and
whatever I try, the filter is ineffective (returns no records) when I use
any of these attempts.

I have tried:
         Filter = "FKCompanyID= [Forms]!frmOrders![txtWholesalerID]"
         Filter = "FKCompanyID= [Forms]!frmOrders!txtWholesalerID"
         Filter = "FKCompanyID=
[Forms]!frmOrders!Controls("txtWholesalerID")
         Filter = "FKCompanyID= [Forms]!frmOrders!cboWholesaler.Column(0)
         Filter = "FKWholesalerID=
Forms(""frmOrders"").Controls(""cboWholesaler"").Column(0)"
         Filter = "FKWholesalerID=
Forms(""frmOrders"").Controls(""txtWholesalerID"")"

Finally, getting desperate, I tried a UDF GetWholesalerID() which returned
the value of one of the controls above, and that would work in the filter.

         Filter = "FKWholesalerID=" & GetWholesaler()

The annoyance though, is that I need to call this in the AfterUpdate event
of the control that drives it, since the function is not volatile - as
reference to a control would be on its own.

Is there any form of compliant syntax which will allow me to establish a
direct dependence between the filter and the referenced control?



--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list