From: szag via AccessMonster.com on 14 Apr 2010 14:48 I know am looking for the best way to accomplish the following: I often have situations where I need to interchange a criteria for the same report. For instance I have a report that I want to look up just projects that are active but I also need that same report to show all projects sometimes. What is the best way to assign an "active" or "all" status criteria into the report. Thanks. -- Message posted via http://www.accessmonster.com
From: Duane Hookom on 14 Apr 2010 18:00 I typically build a WHERE CONDITION in code that checks user entered/selected values from controls and uses the criteria in the DoCmd.OpenReport method. I expect there may be more than two status values so I present them to the user in a multi-select list box. I use a generic function to loop through the selected items of the list box. If no items in the list box are selected then nothing is added to the WHERE CONDITION. -- Duane Hookom Microsoft Access MVP "szag via AccessMonster.com" wrote: > I know am looking for the best way to accomplish the following: > > I often have situations where I need to interchange a criteria for the same > report. For instance I have a report that I want to look up just projects > that are active but I also need that same report to show all projects > sometimes. What is the best way to assign an "active" or "all" status > criteria into the report. > > Thanks. > > -- > Message posted via http://www.accessmonster.com > > . >
From: szag via AccessMonster.com on 14 Apr 2010 18:08 Thanks Duane - I am kind of a hack when it comes to code. Is it possible to show a quick example of how the where condition would work with the control that has an "Active", "Inactive" selection? Duane Hookom wrote: >I typically build a WHERE CONDITION in code that checks user entered/selected >values from controls and uses the criteria in the DoCmd.OpenReport method. > >I expect there may be more than two status values so I present them to the >user in a multi-select list box. I use a generic function to loop through the >selected items of the list box. If no items in the list box are selected then >nothing is added to the WHERE CONDITION. > >> I know am looking for the best way to accomplish the following: >> >[quoted text clipped - 5 lines] >> >> Thanks. -- Message posted via http://www.accessmonster.com
From: Marshall Barton on 14 Apr 2010 18:37 szag via AccessMonster.com wrote: >I know am looking for the best way to accomplish the following: > >I often have situations where I need to interchange a criteria for the same >report. For instance I have a report that I want to look up just projects >that are active but I also need that same report to show all projects >sometimes. What is the best way to assign an "active" or "all" status >criteria into the report. Use buttons on a form to open the reports. If you have a separate button for each condition, the code would look like: Dim strWhere As String strWhere = "Status='Active' " DocCmd.OpenReport "thereport", acviewPreview, , strWhere and for the all projects button: DocCmd.OpenReport "thereport", acviewPreview Or, if you have something like a check box for users to indicate they want active or all, a single button can do either: Dim strWhere As String If Me.thecheckbox Then 'only active projects strWhere = "Status='Active' " DocCmd.OpenReport "thereport", acviewPreview, , strWhere Else 'all projects: DocCmd.OpenReport "thereport", acviewPreview End If -- Marsh MVP [MS Access]
From: szag via AccessMonster.com on 15 Apr 2010 07:43
This is great Marshall! Marshall Barton wrote: >>I know am looking for the best way to accomplish the following: >> >[quoted text clipped - 3 lines] >>sometimes. What is the best way to assign an "active" or "all" status >>criteria into the report. > >Use buttons on a form to open the reports. If you have a >separate button for each condition, the code would look >like: >Dim strWhere As String > strWhere = "Status='Active' " > DocCmd.OpenReport "thereport", acviewPreview, , strWhere > >and for the all projects button: > DocCmd.OpenReport "thereport", acviewPreview > >Or, if you have something like a check box for users to >indicate they want active or all, a single button can do >either: > >Dim strWhere As String > If Me.thecheckbox Then 'only active projects > strWhere = "Status='Active' " > DocCmd.OpenReport "thereport", acviewPreview, , strWhere > Else 'all projects: > DocCmd.OpenReport "thereport", acviewPreview > End If > -- Message posted via http://www.accessmonster.com |