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

Filtering a report

Status
Not open for further replies.

JanesC

Technical User
Jan 15, 2002
29
GB
I would like to preview a report when a user clicks a button in a form. But i only want it to display records where [Duck] matches what has been entered on the form. For example if [Duck] contained the text 'black' the report would only show black ducks.

Could someone give me idiot proof instructions on how to do this?

Private Sub Command149_Click()
On Error GoTo Err_Command149_Click

Dim stDocName As String

stDocName = "rptYour_Duck"
DoCmd.OpenReport stDocName, acPreview

Exit_Command149_Click:
Exit Sub

Err_Command149_Click:
MsgBox Err.Description
Resume Exit_Command149_Click

End Sub



Ta very much
Jane [lipstick]
 

change to,

Code:
DoCmd.OpenReport stDocName, acPreview, ,"Duck=" & Me!Duck

HTH,


Shri
 
Thanks for your speedy response!

I've tried that out and when i click my button a box comes up saying 'Enter Parameter Value' Underneath it says 'black'

If i enter black in the box, the report comes up exactly as i want it. But is there a way to get it to enter black in the box for me. Or instead of saying black can i put my own message, such as 'Please enter colour of duck below'?

 
oops,

dont forget the singlq quotes around black,

Code:
,"Duck='" & Me!Duck & "'"


HTH,


Shri
 
Cheers! I'm off down the pub now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top