Optio Group

S

SAVLO

I have created an option group on a form with 4 buttons all are pointing to a
report. 3 are working properly Option 4 invokes a list box for a user to
choose an particular group to include in the report. I believe there needs
to be something in the properties of the report but I’m not sure what. All
reports are generated by a series of queries. Can anyone help?
The following is the code I used:

Dim strWhereSelectGroup As String

strWhereSelectGroup = "[Asset Group].GroupDescription =
Forms![Print/Preview]!SelectGroup"

Select Case Me!ReporttoPrint
Case 1
DoCmd.OpenReport "Cost per Hour 1st Quarter 2007", PrintMode
Case 2
DoCmd.OpenReport "Hourly Cost by Category", PrintMode
Case 3
If IsNull(Form![Print/Preview]!SelectGroup) Then
DoCmd.OpenReport "Hourly Cost by Group", PrintMode
Else
DoCmd.OpenReport "Hourly Cost by Group", PrintMode, ,
strWhereSelectGroup
End If
Case 4
DoCmd.OpenReport "Cost per Hour by Cost Center", PrintMode

End Select
 
S

SAVLO

I think my problem is in the report filter, I'm going to try your
suggestion. I'll let you know. Thanks

Jim Bunton said:
Are you sure that 'strWhereSelectGroup' is correct?

Open Report . . . .
Where Condition A valid SQL WHERE clause (without the word WHERE) or
expression that Microsoft Access uses to select records from the report's
underlying table or query. If you select a filter with the Filter Name
argument, Microsoft Access applies this WHERE clause to the results of the
filter.To open a report and restrict its records to those specified by the
value of a control on a form, use the following expression:[fieldname] =
Forms![formname]![controlname on form]The fieldname argument is the name of
a field in the underlying table or query of the report you want to open. The
controlname on form argument is the name of the control on the form that
contains the value you want records in the report to match.
Note The maximum length of the Where condition argument is 256 characters.
If you need to enter a more complex SQL WHERE clause longer than this, use
the OpenReport method of the DoCmd object in Visual Basic instead. You can
enter SQL WHERE clause statements of up to 32,768 characters in Visual
Basic.

AND, of course, the field/column to whicg it refers in included in the query
the report runs on

if so the report should simply run with the group identified in the WHERE
Condition - displaying the value on the report if the field/column is
included on the report
SAVLO said:
I have created an option group on a form with 4 buttons all are pointing to
a
report. 3 are working properly Option 4 invokes a list box for a user to
choose an particular group to include in the report. I believe there
needs
to be something in the properties of the report but I'm not sure what. All
reports are generated by a series of queries. Can anyone help?
The following is the code I used:

Dim strWhereSelectGroup As String

strWhereSelectGroup = "[Asset Group].GroupDescription =
Forms![Print/Preview]!SelectGroup"

Select Case Me!ReporttoPrint
Case 1
DoCmd.OpenReport "Cost per Hour 1st Quarter 2007", PrintMode
Case 2
DoCmd.OpenReport "Hourly Cost by Category", PrintMode
Case 3
If IsNull(Form![Print/Preview]!SelectGroup) Then
DoCmd.OpenReport "Hourly Cost by Group", PrintMode
Else
DoCmd.OpenReport "Hourly Cost by Group", PrintMode, ,
strWhereSelectGroup
End If
Case 4
DoCmd.OpenReport "Cost per Hour by Cost Center", PrintMode

End Select
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top