Option Group Report Filter

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hello..

I have a report that I would like users to have the option to filter if they
would like. I have been reading about using a Pop Up form with Option Groups
that would allow me to do this. I know how to set up the Option Group, but am
unsure how to set it up to point to my table in order to apply the filter.

Can anyone point me in the right direction? Give me any pointers?

Thanks,

Brook
 
Create a form, that contains your option group or groups.

Add a command button to open your form. In the click event of this button,
add code that builds a criteria clause that can be used in the OpenForm
method, something like the following. This assumes that your report has two
fields [Field1] and [Field2], with numeric values between 1 and 3. It also
assumes that your form has two option groups(og_Field1, og_Field2) , each
with 4 radio buttons, labeled (N/A, 1, 2, 3) with values of 0, 1, 2, 3. The
reason for the extra stuff in the test for OG_Field2 is that if og_Field1 =
0 , then varCriteria will be NULL. When you add (+) a Null value to a
string, you get a Null value, which will eliminate the "AND". But if
og_Field1 > 0 then varCriteria will be a contain a string, which will need
the "AND" clause to set it off from the criteria for og_Field2. You then
open your report using the OpenReport method, and you pass it your
varCriteria string in place of the WHERE parameter.

Private Sub cmd_Report_Click()

Dim varCriteria as variant

varCriteria = NULL

IF oq_Field1 <> 0 then varCriteria = "[Field1] = " & me.og_Field1

IF og_Field2 <> 0 then
varCriteria = (varCriteria + " AND ") & "[Field2] = " & me.og_Field2
ENDIF

Docmd.OpenReport "YourReportName", acViewPreview , , varCriteria

End SUB

HTH
Dale
 
Back
Top