Link to home
Start Free TrialLog in
Avatar of Bryan Schmidt
Bryan SchmidtFlag for United States of America

asked on

Need help with VBA syntax when referencing an option group for exporting Access reports

I need to give users the option of exporting Access reports in PDF or XPS format.  The code used for exporting the reports works fine, but I need help finding the syntax that will run the correct set of code once users have selected their desired exporting option.  There are two sets of code to run; if a user selects the PDF option then the syntax for exporting in PDF runs.  If the user selects the XPS option then the syntax for exporting in XPS runs.  

I created an option group with two buttons: PDF (name is optPDF; value = 1) or XPS (name is optXPS; value = 2).  The default is PDF.  I now realize that what matters is which button has the focus.  Thus, saying if Me.optPDF.value = 1 (or Me.optXPS.value =2) doesn't matter.  I'm guessing I need to say something like if Me.optPDF.HasTheFocus then proceed to run the code for exporting reports.

I'm familiar with Select Case statements but cannot find the right combination of syntax to make them work.  Please advise if my code needs to identify which option button has the focus and, if so, what is the correct syntax for that.  If there is a better way to do this I'm would appreciate any suggestions.
SOLUTION
Avatar of Helen Feddema
Helen Feddema
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
An If ... ElseIf ... End If statement works fine if you just have two options.
Avatar of Bryan Schmidt

ASKER

See my comments above as to why I accepted my own solution.  For my purposes it worked the best, but I want the points awarded to Helen Feddema as I would not have been able to solve this without her help.