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

Show criteria in reports 2

Status
Not open for further replies.

brucomela

Programmer
Oct 15, 2001
52
0
0
IT
Hoe can I show the criteria used to filter a table in the report generated? I mean: my a user applies the function "select by form" (using the button on the menu bar), then he can push a button and get a report containing filtered data (report is sinchronised using vb code with the form)he selected, but how can he remember fields he specified with "select by form"?! or better how can I print these criteria in the report together with data?!I hope I was clear, help me or ask me to explain better please!
 
Me.filter? And where should I write this piece of code to show form filter in the report?? i don't know if I was clear: I know how to syncronize form and report, but I want to specify in the report the criteria actually used to filter data. I don't know how to work this out, cause the user will filter using "select by form" so it's impossible to foresee the criteria he will choose! For example he might select all the person named "Paul", and I want to show on top of the report "these are all the records whose name is "Paul""
 
Can you e-mail the form and report and code to synch. My e-mail is twschafer@west.com
 
Sorry pezamystic, but I'm not authorised to export pieces of this project. Anyway there's a Me.filter to synchronise form and report, nothing else. Form contains names, and personal informations, report just lists the names of selected persons. Filter is made using "select by form" (you know, when the mask gets cleared and you can freely specify a criteria on each field). Is there a way to make the selected criteria appear on top of the report? Thanks in advance if u can help also without seeing materials (it doesn't depend on me!)
 
try to include a parameter(filter) when opening the report
 
?? I need to only show the used filter in a report, but the filter was freely applied in a form using "select by form" button on the menu bar!! Report is perfectly sinchronised with form, but criteria are not explicit on it
 
Try this add a textbox to your reports Report Header called txtFilter.
Add this code to your report- Make sure to enter your Form's name.

Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)

Let Me.txtFilter = Forms("[Enter Your Form Name Here]").Filter

End Sub

 
Thanks Pezamysti,

That advice was really helpful to me also!!

ZaZa
 
Hi,

Thanks to Pezamystick, I can now show the criteria in a report. BUT I HAVE A COMPLICATION:

I used list boxes and combo boxes on a form to allow the user to select a combination of criteria. By hitting a button, the report would run with the selected criteria as the filter. However these list boxes and combo boxes did not show the primary keys as I kept them "hidden" from the user ( the 'bound column' of the list box was given a 'column width' of 0).

By showing the criteria usng Me.Filter, the actual primary key values are being shown in the report and this would make no sense to the user. Is there is way to display the criteria showing EXACTLY WHAT THE USER SAW WHEN MAKING HIS/HER SELECTIONS??

If any one is confused , please say so and I will try to explain again.

Regards,
lisa [wiggle]
 
You would have to hit the db again to get the values the user had selected. Use the form wizard to build a form using all fields from the msysobjects table. Add a button named Pezs to the form and attach the following code....

Private Sub Pezs_Click()

Dim rs As Recordset
Dim strMSG As String

Set rs = CurrentDb.OpenRecordset("select name from msysobjects where " & Me.Filter)

While rs.EOF = False
strMSG = strMSG & ", " & rs!Name
rs.MoveNext
Wend

MsgBox strMSG

rs.Close
Set rs = Nothing

End Sub

Open the form and filter it then click the button.


Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top