• Options (Access 2000)

    Author
    Topic
    #359742

    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

    Viewing 3 reply threads
    Author
    Replies
    • #540102

      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.

    • #540104

      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:

      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
    • #540106

      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

      • #540111

        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.

        • #540144

          Oops! The first line should read “Select Case Frame0”. I keep telling Elaine she should integrate a VBA editor into the Lounge!

    • #540114

      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

      • #540117

        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.

    Viewing 3 reply threads
    Reply To: Options (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: