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

filter on a report

Status
Not open for further replies.

tazibc

Instructor
Oct 5, 2007
66
GB
Can any one tell me how to inserta filter onto a report,

I have a feild [Service Centre / Satellite] but all I want report to show me the above feild must equal to "Basingstoke".

pls help
 
You can filter on Docmd.OpenReport the same way you filter on OpenForm().

Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.

 
Harley your the man.....

where would I insert the code

DoCmd.OpenForm "Crystal Compliance Database", , , "[Service Centre / Satellite] = 'Basingstoke'"

not sure where this event will go
 
Do you mean?
Code:
DoCmd.OpenReport "The name of your report", , , "[Service Centre / Satellite] = 'Basingstoke'"
Put that in the event for opening the report (i.e. if you open the reoprt from a button click put it in there).

Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.

 
Thanks Harley but when I inserted a button to run the report in my form1 and in the event properties I inserted teh following code:-

Private Sub Command129_Click()
On Error GoTo Err_Command129_Click

Dim stDocName As String

stDocName = "Crystal Compliance Database"
DoCmd.OpenReport "Crystal Compliance Database", , , "[Service Centre / Satellite] = 'Basingstoke'"
DoCmd.OpenReport stDocName, acPreview

Exit_Command129_Click:
Exit Sub

Err_Command129_Click:
MsgBox Err.Description
Resume Exit_Command129_Click

End Sub

this brings back over 240 pages including data for all service centers and no basingstoke specific
 
You open the report with different criteria straight after, that'll be what you're seeing. Try:
Code:
stDocName = "Crystal Compliance Database"
    DoCmd.OpenReport stDocName, acPreview, , "[Service Centre / Satellite] = 'Basingstoke'"
   'DoCmd.OpenReport stDocName, acPreview
Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.

 
The real syntax is:
Code:
DoCmd.OpenReport stDocName, ac[!]View[/!]Preview, , "[Service Centre / Satellite] = 'Basingstoke'"
 
Good spot there PHV, I got preoccupied with the second OpenReport method and missed that completely.

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.

 
you guys are the best this works a treat thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top