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

Open report filtered from an option group

Status
Not open for further replies.

Hoving

Technical User
Apr 8, 2002
21
US
How do I open a report filtered from an option group?

I have a report, rptEveryone, based on a query, qryEveryone. One field in the query and on the report is called DoctorName.

I have an option group, optSelectReport, on a main form, frmMain. The option group has 3 options. When the user
selects the 3rd option (labeled "Preview Report for Doctors only") and hits a command button, cmdPreview, I'd like rptEveryone to open filtered for records where the DoctorName is not null. Right now the report opens unfiltered, because I don't know how to write what I assume should be a Where statement (like "Where DoctorName Is Not Null).

Here's what I have so far in the code of frmMain:

**************************************
Sub PrintReports(PrintMode As Integer)
On Error GoTo Err_Preview_Click
' This procedure used in Preview_Click sub procedure.

Select Case Me!optSelectReport
Case 3
DoCmd.OpenReport "rptEveryone", PrintMode

End Select

Exit_Preview_Click:
Exit Sub
Err_Preview_Click:
Resume Exit_Preview_Click
End Sub
----------------------------------
Private Sub cmdPreview_Click()
PrintReports acPreview
End Sub
**************************************

Thank you for any help.

Hoving




 
Hi,
You could try the following idea:

1) Create a query using the Query Designer in Access.

2) Base this query on the table that contains your data.

3) Under the DoctorName column, set the criteria to Not Null.

4) Set the record source of your report to this query.

5) Open the report. Hope it helps. Let me know what happens.
With regards,
PGK
 
one way to do it is on OPEN of the report have:

------

SELCT CASE Forms!frmMain.optSelectReport

CASE "Type 1"
'Type 1 Filer
CASE "Type 2"
'Type 2 Filter
CASE "Preview Report for Doctors only"
Me.Filter = &quot;DoctorName <> ''&quot;

END SELECT

Me.FilterOn = True

--------

Not sure on the actual syntax of the filter but play arround with it a bit and let me know if it works
 
The SELECT CASE Forms!frmMain.optSelectReport . . . statement in the Open event of the report was exactly what I was looking for. It works perfect.

Creating an additional query as suggested would have worked, too, but I wanted to avoid creating another query if there was a more efficient way. One less query to worry about.

Thanks.

Hoving
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top