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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter on 1

Status
Not open for further replies.

villica

Programmer
Feb 25, 2000
332
CA
Hi everyone

I have an access database that does not longer work in access 2007
I think the problem is here. It does not apply the filter
Reports("rpt sample").Filter = "ID=" & lstCFAMS.Value


villica
 

You are giving us very little (practically nothing) to work with here.
1. What do you mean by "does not work"?
2. Why do you think the statement you provided is causing the problem? perhaps Reports("[rpt sample]).Filter...



Randy
 
Furthermore, why not using the 4th parameter of the DoCmd.OpenReport instead ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
When the report opens up, it has a query as a record source which has every record. Also when the report opens up another little form opens up and with list of names. When I click on any of the names the report used to display only that name and the transaction for that name only instead of every record.


Now when I click on any of the names it does not do anything at all. I apologize for not been more specific before

villica
 
villica from duplicate thread (thanks dhookom):
When the report opens up, it has a query as a record source which has every record. Also when the report opens up another little form opens up and with list of names. When I click on any of the names the report used to display only that name and the transaction for that name only instead of every record. At this point the report is already open. I am applying a filter on already open report


Now when I click on any of the names it does not do anything at all. I apologize for not been more specific before.



Lameid, I have already put space and set the filter on. It seems that the filter on works but it also closes the little form


Reports("sample").Filter = "ID = " & lstCFAMS.Value
Reports("sample").FilterOn = True


I will look up how to use the where clause

Instead of opening the report AND the form just open the form.

Where the form changes the filter now, run the report with a filter.

Code:
docmd.OpenReport "sample", acViewPreview,,"ID = " & lstCFAMS.Value
 
As per a reply in another thread, please post in one thread only. I use the method suggested by PH. Open the report from a form using the Where Condition of the DoCmd.OpenReport method.
Code:
Dim strWhere as String
Dim strRptName as String
strRptName = "rptWhatever"
strWhere = "1=1 "
If not IsNull(Me.lstCFAMS) Then
   strWhere = strWhere & " AND ID=" & lstCFAMS
End If
DoCmd.OpenReport strRptName, acViewPreview, , strWhere
This assumes ID is numeric. If it is text, change the code to:
Code:
Dim strWhere as String
Dim strRptName as String
strRptName = "rptWhatever"
strWhere = "1=1 "
If not IsNull(Me.lstCFAMS) Then
   strWhere = strWhere & " AND ID=""" & lstCFAMS & """ "
End If
DoCmd.OpenReport strRptName, acViewPreview, , strWhere




Duane
Hook'D on Access
MS Access MVP
 
Use my advice and Duane's code. His is more robust and versatile [thumbsup2]. Mine is just quick and dirty.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top