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

radio buttons to open reports 3

Status
Not open for further replies.

mstekkie

Technical User
May 15, 2002
51
CA
i've got 4 radio buttons and each button opens a different report. what happens is that no matter what option is picked the first time, it always goes to this certain report.

what i want it to do is to open the appropriate report depending on what button the user clicks on; but i don't know how to do it.

any help would be greatly appreciated.

thank you in advance.
 
Well that all depends on what event you're triggering on and generally how you're doing it.

Are these four radio buttons in an option group ?

What event do you trigger on ?

What do you do in that event ?


G LS
 
One easy way to do this is to use macros for each radio button. The wizard for macros is easy to use and I think this will solve your problem. If this is not what you are looking for, or if you need me to explain further, let me know. Thanks.
 
GLS - the radio buttons are in an option group. each radio button opens a report. is that what you mean by what event it triggers?

jbento - i'm not very familiar with macros. how would i go about doing that?
 
Here's how you do it. First, use the wizard to create an option group. It'll prompt you to type in a label for each report. Make sure you write those down alongside the number assigned to it--you'll need them to refer to later on. Then create a button for either Print or Preview (or a button for each).

Right click on one of button for the shortcut menu and choose Properties. Click the Event tab. For the On Click option, chose Event Procedure. Click the ... button next to that to go the visual basic window. Add the following code in:

Private Sub cmdPreview_Click()
On Error GoTo ErrorPreview

Select Case [fraPrint]

' Each of these case numbers represent an item in the option group. Insert the report that matches the corresponding number

Case Is = 1
DoCmd.OpenReport "rptName1", acViewPreview

' For sending the report directly to the printer, use acViewNormal instead of acViewPreview

Case Is = 2
DoCmd.OpenReport "rptName2", acViewPreview

Case Is = 3
DoCmd.OpenReport "rptName3", acViewPreview

Case Is = 4
DoCmd.OpenReport "rptName4", acViewPreview

End Select

ExitPreview:
Exit Sub


ErrorPreview:
Msgbox err.Description
Resume ExitPreview
End Sub

Linda Adams
Visit my web site for writing and Microsoft Word tips: Official web site for actor David Hedison:
 
Linda,

do i keep all the other code that was generated by the wizard? and do i keep the case statements as case is = 1 or do i change them to the name of the option buttons?
 
The option group itself returns an INDEX VALUE which is numeric, 1 - 4 in this case.
It does NOT return the name of the button.
So the Select Case statement must look for
Case = 1
Case = 2
etc.

Keep the
On Error Goto
at the top and
Error handling lines at the bottom.

Other than that, what else has the wizard deemed it appropriate to dump on you ?


G LS
 
GLS,

the wizard has also included these lines of code, i didn't think they were necessary so i erased them.

Dim stDocName As String

stDocName = "rptCompanyDate"
DoCmd.OpenReport stDocName, acNormal

i left the error handling statements in. when i click on the preview button, it gives me the error:

can't find "|" in the required expression

i don't know what that means.

thanks for your help :)
 
Did you rename the overall option group fraPrint? You have to go into the properties (click on the overall option group and click the Properties button). Select the Other tab. In the Name field, enter fraPrint.
Linda Adams
Visit my web site for writing and Microsoft Word tips: Official web site for actor David Hedison:
 
thank you so much Linda. i got it to work perfectly!

cate :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top