Kimmer181
02-05-2002, 08:20 AM
Okay, I could use a little help...
I have developed an option group on a "tab control" form which has 35 option buttons. I am trying to figure out how I can allow the user to click on a single option button, hit a "print preview" control button and have that one specific report (out of 35)show up on the screen. I believe I need to set up a macro but I can't seem to get the expression right. If any one has any ideas (and examples)please let me know. Perhaps I ddon't need a macro? I am lost at this point....
Thanks.
Kim
Alexandre
02-05-2002, 12:21 PM
I believe that the easiest solution would have been to use a combo (eventually a listbox) instead of an option group. You could use an (eventually hidden) column from the combo or list box to hold the name of the reports you have, and read and use this value from the on-click event of your command button.
If you are really keen on using an option group, you could for example use the Tag property of your controls to hold the reports names, then use them the same way than above... or use a select case statement.
As you see this result in heavier solutions than the above.
Alex
[This message has been edited by Alexandre (edited 02-05-2002).]
Kimmer181
02-06-2002, 05:29 AM
Thanks Alex.
I am open to any method of accomplishing this task. My biggest problem is that I don't know how to build an "event procedure". Okay, say I have the following three reports:
1) System #1
2) System #2
3) All Systems
My initial thoughts were to have these reports identified with option buttons (Properties: Option Value 1, Option Value 2, etc.). The user would then be able to select the report they want to view and then click on a command button to preview that specific report. However, I don't know how to write an "expression" for the command button that will accomplish this. Any idea on how to build an "On Click" event procedure (or macro) that would work??
For example, this is what I want to do but I can't seem to develop the right (string)expression:
if OptionValue1 the OpenReport System1; if OptionValue2 then OpenReport System2; etc.
Thanks.
Kim
Alexandre
02-06-2002, 12:17 PM
Sorry for the delay. Had quite a busy day.
There are various ways to populate your combobox with reports names.
-Simple one, but not very flexible:
Set the recordsource type of your combo to "value list" and enter a value list in the recordsource like the following:
"ReportName1";"ReportDescritpion1":"ReportName2"; "ReportDescritpion2" etc.
Set your combo properties to 2 columns; unbound column:1 (the column holding reports names); columns widths: 0;10 cm (hide the first column and just show the description to the users)
This is not flexible because with every new report in your DB you would have to edit the combo box properies and modify the list.
-Following method is more efficient:
The following query is an can populate you combobox with the names of reports existing in your DB.
SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1) <> "~")
AND (MSysObjects.Type)= -32764 ORDER BY MSysObjects.Name;
Limitation here is that you cannot as easily associate a description to to your reports names. They have to be very explicit.(They are other better solutions but slightly more complicated)
The query uses an Access system table that self-document the various objects of your DB. They are automatically updated with any changes in your DB. You can implement a code in naming your report to selectively show only the reports you want (not the sub-reports for example). Ex: call the reports you do not want to show: Rpt_... then put the criteria Not Like "Rpt_*" in your query.
Now, opening the report a user selected in your combo is easy.
Using the on.click event of your command button and assuming that the name of your combo is cbReportsList:
Docmd.OpenReport Me.cbReportsList.column(0)
See help on OpenReport to learn about the various possible parameters: you can specify a filter, where clause, opening mode, etc
Hope this helps
Alex
[This message has been edited by Alexandre (edited 02-06-2002).]