Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Filter problem

Status
Not open for further replies.

Moss100

Technical User
Aug 10, 2004
584
GB
Can someone help me with the following, which is not working for me.

Thank you Mark

Code:
Me.Form.Filter = [Ten_Lease_Start_Date] < DateAdd("yyyy", -6, Int(Now()))
 
What makes you think it's not working?
Have you tried just Date() in place of Int(Now())?

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
The code sets True/False to Filter, a string should be instead:
Me.Form.Filter = "[Ten_Lease_Start_Date] < " & DateAdd("yyyy", -6, Date())

combo
 
I my opinion, the safest way to do it is:

Code:
Dim strFilter As String
...
strFilter = "Ten_Lease_Start_Date < " & DateAdd("yyyy", -6, Date())
Debug.Print strFilter
Me.Form.Filter = strFilter

So you can actually SEE your filter before you apply it.

BTW, you do not need [] around your field's name if you do not use spaces or reserved words in your fields' names.

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top