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

Jim Dettman jimdettman at verizon.net
Thu Dec 25 17:18:02 CST 2014


 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



More information about the AccessD mailing list