Using Option Buttons

  • Thread starter Thread starter SiH23
  • Start date Start date
S

SiH23

I would be really grateful if someone could offer some advice.

I have several queries that I would like to open from a form using Option
Buttons. For example; you select the Option Button next to the Query and
click a button to run the query.

Any help or advice on how I can achieve this would be greatly appreciated.

Regards,

Simon.
 
You can use a Select Case statment in the After Update event of the Option
Group control to run the query associated with the button. You do not worry
about the individual button, but the return value of the Option Group
control. Each button has an Option Value property. That is the value
assigned to the Option Group control when the button is clicked. It is as
simple as:

Private Sub optReportSelector_AfterUpdate()
Dim strRptName As String

Select Case Me.opgReportSelector
Case 1
strRptName = "rptManagementDelusions"
Case 2
strRptName = "rptUslessInfo"
Case 3
strRptName = "rptMeaninglessStatistics"
End Select
Docmd.OpenReport strRptName
End Sub

Now, having said that, I would suggest you not use this approach. That is
because each time a new report is added to your system, it will require code
modification and redistribution.

A better technique is to use a combo box with two columns. The first column
is the actual report name and the second is a textual description of the
report. You hide the first column using the combo's Column Width properties
so the user only sees the description. The you have a table with two
fields, one for the name of the report and one for the description. Your
combo's row source would be a query on the reports table.

Then you use the After Update event of the Combo box to run the report.
Using this technique, adding a report requires no modification to your
application - only an additional row in your table.
 

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

Back
Top