Radio Button Value in Option Group

  • Thread starter Thread starter Chuck
  • Start date Start date
C

Chuck

I am trying to change the record source for a report,
depending on which radio button is selected in an option
group.

--------------------------------------------------------
If (Forms!frmReports!FrameSO!optBuyer.Value = True) Then
Reports!rptStndOrder.RecordSource = "zqryStndOrderB"
else
Reports!rptStndOrder.RecordSource = "zqryStndOrderC"
End If
 
Chuck said:
I am trying to change the record source for a report,
depending on which radio button is selected in an option
group.

--------------------------------------------------------
If (Forms!frmReports!FrameSO!optBuyer.Value = True) Then
Reports!rptStndOrder.RecordSource = "zqryStndOrderB"
else
Reports!rptStndOrder.RecordSource = "zqryStndOrderC"
End If

I think you may have more than one problem...

#1 - Normally you would use the value of the Frame, not the radio buttons

Ex:
Select Case Forms!frmReports!FrameSO
Case 1 'This is assuming that 'Buyers' is #1
Reports!rptStndOrder.RecordSource = "zqryStndOrderB"
Case else
Reports!rptStndOrder.RecordSource = "zqryStndOrderC"
End Select

#2 - I believe that you have to have a report in Design mode to change the
record source. Are you sure there isn't a better way to handle that on the
fly? Perhaps using different reports to handle your different situations?
 
Did you use the Control Wizard to create your option group? If so, it
assigns numeric values to the options by default: 1, 2, 3, etc.
 
Cheryl, I did use the Control Wizard to create my option
group. Jeff, I was testing the if then else
functionality to get it to work, but planning to
implement the Case Select structure (due to have three
different queries). I currently have 3 versions of the
same report 5x (total of 15). I am looking at the radio
group functionality to remove 10 reports. This will
enable the user to select the report and filter with
desired radio button/query. Thank you both for your
quick responses.
 
Chuck said:
Cheryl, I did use the Control Wizard to create my option
group. Jeff, I was testing the if then else
functionality to get it to work, but planning to
implement the Case Select structure (due to have three
different queries). I currently have 3 versions of the
same report 5x (total of 15). I am looking at the radio
group functionality to remove 10 reports. This will
enable the user to select the report and filter with
desired radio button/query. Thank you both for your
quick responses.

Chuck,

If filtering is what you need, you can do that on the fly. If I can make a
couple of assumptions:
#1 - Your structure behind all of the reports must be the same, correct?
Built from the same table or query with different critieria (i.e.
Jobcode="Buyer" or Jobcode = "Seller"?

If that is the case then you can use the select command or the IFelse
command and come up with different criteria for a single report.

Ex
Dim stLinkCriteria as string
Const stDocName = "ReportWithEverything"

Select Case FORM!Option
Case 1 'Buyer'
stLinkCriteria = "JobCode='Buyer'"
Case 2 'Salesperson
stLinkCriteria ="JobCode='Salesperson'"
End Select

DoCmd.OpenReport stdocname, acViewPreview, , stLinkCriteria

Maybe that will help?
 
Back
Top