A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Open report to current year



 
 
Thread Tools Display Modes
  #1  
Old May 25th, 2010, 03:57 AM posted to microsoft.public.access.reports
Billy B
external usenet poster
 
Posts: 42
Default Open report to current year

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
  #2  
Old May 25th, 2010, 04:56 AM posted to microsoft.public.access.reports
PieterLinden via AccessMonster.com
external usenet poster
 
Posts: 307
Default Open report to current year

You mean to tell us that you got the hard part down and you couldn't figure
out the easy part???
You just need to tack on the filter for dates... something like

WHERE ...
AND Year([DateField]) = Year(Date())

--
Message posted via http://www.accessmonster.com

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:38 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.