Results 1 to 8 of 8
  1. #1
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Options (Access 2000)

    I have 1 button, cmdPreviewRpt

    I have 2 option buttons, 1)optTCHistory and 2)optBenefits

    I want cmdPreviewRpt to open a report that is determined by the choice of either optTCHistory or optBenefits.

    I have the following code but it returns the message "You entered an expression that has no value". WHY? What have I done wrong? Please help.

    If Me!optTCHistory = 1 Then
    DoCmd.OpenReport "rptEmployee", acViewPreview, "", "", acNormal
    Else
    If Me!OptBenefits = 1 Then
    DoCmd.OpenReport "rptEmployee Benefits", acViewPreview, "", "", acNormal
    End If
    End Sub

    Basically, if the user selects TCHistory then the History Report opens, if the user selects TCBenefits, the the Benefits report opens.

    Thanks ....

    Roberta Newton
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  2. #2
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Indiana, USA
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Options (Access 2000)

    Roberta, I don't think you need the If statement. In the OnClick event of each option button, just write in the DoCmd.OpenReport "ReportName".

    See if that works.

  3. #3
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    USA
    Posts
    379
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Options (Access 2000)

    Are these option buttons in an option group? If it is a mutually exclusive choice, it seems that might be appropriate.
    If so, you want to base the decision on the value of the option group, as in:

    <pre>Select Case vOptionGroup (the name of the option group)
    Case 1,
    DoCmd.OpenReport "rptEmployee", acViewPreview, "", "", acNormal
    Case 2, (or the value of your second option group button)
    DoCmd.OpenReport "rptEmployee Benefits", acViewPreview, "", "", acNormal
    Case Else
    MsgBox ("Choose a Report")

    End Select</pre>


  4. #4
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Options (Access 2000)

    Roberta,

    Where these 2 buttons set up so that when when is selected, then the other is deselected? If so, then you must deal with the Frame that they both are in. Whatever it's name, you can probably handle it this way:

    Select Frame0.Value
    Case 1
    ' do your first DoCmd.OpenReport here
    Case 2
    ' do your other Docmd.openreport here
    Case Else
    msgbox "Hey! You didn't select anything!", vbexclamation
    end select
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  5. #5
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Options (Access 2000)

    Mark,

    I tried your suggestion and get the an error "expecting case" when putting in the first line of code.

    When trying the suggestion posted prior to yours, both buttons are enabled and I get the same report no matter what option button I select.

    Any more suggestions...before ALL of my hair is gone?

    p.s...by the way..yes, both options buttons are in an option group.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wetherby, Yorkshire, England
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Options (Access 2000)

    Try this:
    If "Your Option Group Name (not Me!optTCHistory)" = 1 Then
    DoCmd.OpenReport "rptEmployee", acViewPreview, "", "", acNormal
    Else
    DoCmd.OpenReport "rptEmployee Benefits", acViewPreview, "", "", acNormal
    End If
    End Sub
    This defaults to the second option. You could of course, turn it round. But I think you must have the name of the whole option group rather than the name of each option.
    Best of luck.
    Peter herworth

  7. #7
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Options (Access 2000)

    Hello Everyone,

    Thanks for all the suggestions. What I finally did to get this to work: Change the code to:
    If Me!fmePrintOptions = 0 Then
    DoCmd.OpenReport "rptEmployee", acViewPreview, "", "", acNormal
    Else
    DoCmd.OpenReport "rptEmployee Benefits", acViewPreview, "", "", acNormal
    End If
    Change the default value on optTCHistory to "0" and optBenefits to "1".

    Thanks everyone.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  8. #8
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Options (Access 2000)

    Oops! The first line should read "Select Case Frame0". I keep telling Elaine she should integrate a VBA editor into the Lounge!
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •