Why “Run time error ‘247.You entered an expression that has no value. with check box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jerry Maiapu
    Contributor
    • Feb 2010
    • 259

    Why “Run time error ‘247.You entered an expression that has no value. with check box

    Can someone help me with this funny problem?
    I just created a custom criteria form that a user enters data to open a report.
    .
    I have two unbound check boxes namely 1. chkshowcredits and 2. chknocredits that a user must select/tick one of them before opening the report.

    The on click event (code) of the OK button on the form to preview the report is below:


    Code:
    Private Sub Command6_Click()
    If IsNull(Me.Oyear) = True Or IsNull(Me.ndate) = True Then
    MsgBox "One of the required dates is missing", vbCritical + vbOKOnly, "Date Error"
    End If
    If Me.Oyear <= Me.ndate Then
    MsgBox "Oldest date must be less than Newst date", vbCritical + vbOKOnly, "Date Error"
    Exit Sub
    End If
    
    [B]If me.chkshowcredits.Value = True Then[/B]'error occurs here
    DoCmd.OpenReport "Summary with Credits", acViewPreview
    [B]ElseIf me.chknocredits.Value = True Then[/B]'error occurs here
    DoCmd.OpenReport "Summary With No Credits", acViewPreview
    Else
    MsgBox "Select an option to show or not to show credits in the report", vbCritical + vbOKOnly, "Data Missing"
    End If
    End Sub
    Rest of the validation in the code above is fine but the error message occurs exactly at code line#10 and could possibly occur again at line#12, i.e when I debug it. An this is to do with the two unbound check boxes.

    What is the problem.? I just want the user to tick one of the check boxes to open a particular report based on the check box ticked.
    I am I wrong somewhere.?

    Can one smart person help me out here. I tried to solve this but its hurting my brain.

    Thanks..
  • ahmedtharwat19
    New Member
    • Feb 2007
    • 55

    #2
    HI Jerry Maiapu


    Code:
    If Me.chkshowcredits.Value = True Then'error occurs here 
    DoCmd.OpenReport "Summary with Credits", acViewPreview 
    ElseIf Me.chknocredits.Value = True Then'error occurs here
    I THINK THE ERROR IN THIS CODE REASON TO
    THE VALUE IS NOT EQUAL TRUE OR FALSE JUST EQUAL A NUMBER

    TRUE=1,FALSE=0 IN CHECKBOX

    TRY THIS CODE AND TELL ME

    Code:
    If Me.chkshowcredits.Value = 1 Then 'EDIT BY [B]MEDO[/B]
    DoCmd.OpenReport "Summary with Credits", acViewPreview 
    ElseIf Me.chknocredits.Value = 1 Then'EDIT BY [B]MEDO[/B]
    BEST REGARDS ,

    AHMED THARWAT(MEDO)

    Comment

    • Jerry Maiapu
      Contributor
      • Feb 2010
      • 259

      #3
      Originally posted by ahmedtharwat19
      HI Jerry Maiapu


      Code:
      If Me.chkshowcredits.Value = True Then'error occurs here 
      DoCmd.OpenReport "Summary with Credits", acViewPreview 
      ElseIf Me.chknocredits.Value = True Then'error occurs here
      I THINK THE ERROR IN THIS CODE REASON TO
      THE VALUE IS NOT EQUAL TRUE OR FALSE JUST EQUAL A NUMBER

      TRUE=1,FALSE=0 IN CHECKBOX

      TRY THIS CODE AND TELL ME

      Code:
      If Me.chkshowcredits.Value = 1 Then 'EDIT BY [B]MEDO[/B]
      DoCmd.OpenReport "Summary with Credits", acViewPreview 
      ElseIf Me.chknocredits.Value = 1 Then'EDIT BY [B]MEDO[/B]
      BEST REGARDS ,

      AHMED THARWAT(MEDO)
      AHMED THARWAT(MEDO),
      Thank you in trying to help but I tried that too and still the error message is persisting to pop up.

      After many attempts I have just done away with the check box business and am using a combo box for the users to select from the two text values, YES & NO which is fine.

      However if you still have some solution/suggestions do post it.

      Thank you.

      Jerry

      Comment

      • ahmedtharwat19
        New Member
        • Feb 2007
        • 55

        #4
        Originally posted by Jerry Maiapu
        AHMED THARWAT(MEDO),
        Thank you in trying to help but I tried that too and still the error message is persisting to pop up.

        After many attempts I have just done away with the check box business and am using a combo box for the users to select from the two text values, YES & NO which is fine.

        However if you still have some solution/suggestions do post it.

        Thank you.

        Jerry
        Jerry,

        I Need To Help.

        Can You Attach The sample Problem To solve It.

        Comment

        • Jerry Maiapu
          Contributor
          • Feb 2010
          • 259

          #5
          Thank you in showing interest to help. It is really kind of you.
          Ok, first of all I cannot attach the the mdb file coz it is about 17mb but can I give you the form property details and maybe a screen shot of the form?

          Comment

          • MMcCarthy
            Recognized Expert MVP
            • Aug 2006
            • 14387

            #6
            Instead of adding two individual checkboxes add an option group with two possible values. Now the values will default to 1 and 2. You then use a SELECT CASE function to decide what the selection triggers. Something like the following:

            Code:
            'lets assume you name the option group object as rptFrame
            'In the after update event of that object.
            Private Sub rptFrame_AfterUpdate()
            
                SELECT CASE rptFrame
            
                Case 1
                    Docmd.OpenReport "Report1"
            
                Case 2
                    Docmd.OpenReport "Report2"
            
                END SELECT
            
            End Sub

            Comment

            • ahmedtharwat19
              New Member
              • Feb 2007
              • 55

              #7
              Jerry Maiapu,

              Do It In Option Group, I Think It The Best Of You,
              Because The First If The Value of CheckBox1 Is True And You You Check The Secound CheckBox Value To Be True,The First Still True, But In Option Group This Problem Will Done.
              I Attach The Sample For That.

              Best Regards,

              Ahmed Tharwat (Medo)
              Attached Files

              Comment

              • ADezii
                Recognized Expert Expert
                • Apr 2006
                • 8834

                #8
                Originally posted by ahmedtharwat19
                Jerry Maiapu,

                Do It In Option Group, I Think It The Best Of You,
                Because The First If The Value of CheckBox1 Is True And You You Check The Secound CheckBox Value To Be True,The First Still True, But In Option Group This Problem Will Done.
                I Attach The Sample For That.

                Best Regards,

                Ahmed Tharwat (Medo)
                Assuming:
                1. There are no Syntax Errors on the Control Names.
                2. OYear and nDate are Valid Dates.
                3. The Check Boxes are mutually exclusive.
                4. The report Names are correct.
                5. If the above assumptions are all correct, the code listed will work fine.
                  Code:
                  If IsNull(Me.OYear) Or IsNull(Me.nDate) Then
                    MsgBox "One of the required dates is missing", vbCritical + vbOKOnly, "Date Error"
                      Exit Sub
                  End If
                  
                  If Not IsDate(Me.OYear) Or Not IsDate(Me.nDate) Then
                    MsgBox "At least one Invalid Date", vbCritical + vbOKOnly, "Invalid Date Error"
                      Exit Sub
                  End If
                  
                  If CDate(Me.OYear) <= CDate(Me.nDate) Then
                    MsgBox "Oldest date must be less than Newest date", vbCritical + vbOKOnly, "Date Error"
                      Exit Sub
                  End If
                    
                  If Me.chkShowCredits Then
                    DoCmd.OpenReport "Summary with Credits", acViewPreview
                  ElseIf Me.chkNoCredits Then
                    DoCmd.OpenReport "Summary With No Credits", acViewPreview
                  Else
                    MsgBox "Select an option to show or not to show credits in the report", _
                            vbCritical + vbOKOnly, "Data Missing"
                  End If

                Comment

                • ahmedtharwat19
                  New Member
                  • Feb 2007
                  • 55

                  #9
                  Originally posted by ADezii
                  Assuming:
                  1. There are no Syntax Errors on the Control Names.
                  2. OYear and nDate are Valid Dates.
                  3. The Check Boxes are mutually exclusive.
                  4. The report Names are correct.
                  5. If the above assumptions are all correct, the code listed will work fine.
                    Code:
                    If IsNull(Me.OYear) Or IsNull(Me.nDate) Then
                      MsgBox "One of the required dates is missing", vbCritical + vbOKOnly, "Date Error"
                        Exit Sub
                    End If
                    
                    If Not IsDate(Me.OYear) Or Not IsDate(Me.nDate) Then
                      MsgBox "At least one Invalid Date", vbCritical + vbOKOnly, "Invalid Date Error"
                        Exit Sub
                    End If
                    
                    If CDate(Me.OYear) <= CDate(Me.nDate) Then
                      MsgBox "Oldest date must be less than Newest date", vbCritical + vbOKOnly, "Date Error"
                        Exit Sub
                    End If
                      
                    If Me.chkShowCredits Then
                      DoCmd.OpenReport "Summary with Credits", acViewPreview
                    ElseIf Me.chkNoCredits Then
                      DoCmd.OpenReport "Summary With No Credits", acViewPreview
                    Else
                      MsgBox "Select an option to show or not to show credits in the report", _
                              vbCritical + vbOKOnly, "Data Missing"
                    End If
                  Thank You ADezii

                  Comment

                  • ahmedtharwat19
                    New Member
                    • Feb 2007
                    • 55

                    #10
                    I Here To Learn.

                    Thank You For All.

                    Comment

                    • Jerry Maiapu
                      Contributor
                      • Feb 2010
                      • 259

                      #11
                      Thank you all for assistance. Post#8 worked.

                      Comment

                      • Jerry Maiapu
                        Contributor
                        • Feb 2010
                        • 259

                        #12
                        msquared's solution post#6 was interesting too.

                        And yes thanks ahmedtharwat19 for the attachment(post#7).

                        Thanks all.

                        I am happy to be part of this genius community.

                        Much Regards

                        Comment

                        Working...