Open report to current year

Discussion in 'Microsoft Access Reports' started by Billy B, May 25, 2010.

  1. Billy B

    Billy B Guest

    I have a form with a combo box for the user to select criteria to open a
    report. The following code works but I want to add the criteria that the
    records displayed only the current year not all years. Any help will be
    appreciated.

    Private Sub cmdListCodes_Click()
    Dim strFilter As String
    Dim varItem As Variant

    With lstCodeNumbers
    If .MultiSelect = 0 Then
    strFilter = "
    Code:
     = " & .Value
    Else
    For Each varItem In .ItemsSelected
    strFilter = strFilter & "," & .ItemData(varItem)
    Next varItem
    
    If Len(strFilter) > 0 Then
    If .ItemsSelected.Count = 1 Then
    strFilter = "[Code] = " & Mid$(strFilter, 2)
    Else
    strFilter = "[Code] In(" & Mid$(strFilter, 2) & ")"
    End If
    End If
    End If
    End With
    
    'Clear the listbox selected items
    With lstCodeNumbers
    For Each varItem In .ItemsSelected
    .Selected(varItem) = False
    Next varItem
    End With
    
    'Open the report with the selected Codes
    DoCmd.OpenReport "rptTestDescCode", acViewPreview, WhereCondition:=strFilter
    
    End Sub
     
    Billy B, May 25, 2010
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Susy
    Replies:
    0
    Views:
    347
  2. Guest

    Comparing current year and prior year data in one report

    Guest, Feb 20, 2004, in forum: Microsoft Access Reports
    Replies:
    5
    Views:
    968
    Duane Hookom
    Feb 24, 2004
  3. Guest

    Comparing Year to Year Periods in a report

    Guest, Jun 18, 2004, in forum: Microsoft Access Reports
    Replies:
    1
    Views:
    284
  4. Guest

    Getting Fiscal Year instead of Calendar Year

    Guest, Sep 30, 2004, in forum: Microsoft Access Reports
    Replies:
    1
    Views:
    462
    Duane Hookom
    Oct 1, 2004
  5. Guest

    Three year history on report - recordset per year

    Guest, Jul 17, 2006, in forum: Microsoft Access Reports
    Replies:
    3
    Views:
    254
    Larry Linson
    Jul 19, 2006
  6. Nur Muhammad

    Current month and year report

    Nur Muhammad, Apr 15, 2008, in forum: Microsoft Access Reports
    Replies:
    2
    Views:
    248
    Nur Muhammad
    Apr 16, 2008
  7. mogll
    Replies:
    4
    Views:
    657
    mogll
    Jan 26, 2009
  8. pcbins

    Report with current fiscal year in header

    pcbins, Jun 23, 2009, in forum: Microsoft Access Reports
    Replies:
    1
    Views:
    336
    pcbins
    Jun 23, 2009
Loading...