By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,034 Members | 979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,034 IT Pros & Developers. It's quick & easy.

filter question

100+
P: 250
i have a form where i can filter results using the following code

Expand|Select|Wrap|Line Numbers
  1. 'CheckFilter produces the new Filter depending on the values currently in
  2. 'txtFindAccountCode, txtFindCreationDate & cboFindAccountType.
  3. Private Sub CheckFilter()
  4.     Dim strFilter As String, strOldFilter As String
  5.  
  6.  strOldFilter = Me.Filter
  7.     'txtFindCreationDate - Date
  8.     If Me!yearsearch > "" Then _
  9.         strFilter = strFilter & _
  10.                      " AND ([Date1]Like '" & _
  11.                     Me!yearsearch & "*')"
  12.  
  13.    'Tidy up results and apply IF NECESSARY
  14.     If strFilter > "" Then strFilter = Mid(strFilter, 6)
  15.     If strFilter <> strOldFilter Then
  16.         Me.Filter = strFilter
  17.         Me.FilterOn = (strFilter > "")
  18.  
  19.     End If
  20. End Sub
then i have a button coded with "call checkfilter" to filter the results.

i am only looking to filter results by year but my date field is formatted like this "1/1/2010" is there any way i can search for just a four digit year? currently i am doing */*/2010 to find results for 2010...i would prefer to just type 2010... thanks!
Apr 23 '10 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 636
@didacticone
Hi

Try changing the filter criteris to this

strFilter = strFilter & " AND (Year([Date1]) = " & Me!yearsearch & ")"

where Me!yearsearch is an integer year.

HTH


MTB
Apr 23 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.