Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2007
    Posts
    25

    Unanswered: Trouble setting an object variable

    I am using Access 2002.

    I have a subreport, and would like to show or hide an object based upon the value in a calculated field.

    The code I am using is:

    Dim subRpt As Report
    Dim MyObject As Object
    Dim rptVal As String

    Set rptSub = Report_8STEP_SEC3C_SUB_subreport_2.Expr1
    Set MyObject = rptSub
    rptVal = MyObject

    If rptVal = 1 Then
    pic_identified.Visible = True
    Else: pic_identified.Visible = False
    End If
    If Me.Expr1 = 2 Then
    pic_implemented.Visible = True
    Else: pic_implemented.Visible = False
    End If
    If Me.Expr1 = 3 Then
    pic_feedback.Visible = True
    Else: pic_feedback.Visible = False
    End If
    If Me.Expr1 = 4 Then
    pic_closed.Visible = True
    Else: pic_closed.Visible = False
    End If

    When I preview the report I get the error:

    Run-time error '2427':
    You entered an expression that has no value.

    When I mouse over rptVal, I get. rptVal = ""

    I have lost track of all of the iterations of this code I have tried.
    I have received the error Run-time error '91':
    I have received the error Run-time error '13':

    I would appreciate any help you may be able to offer.
    Kirk Wahl
    GM Powertrain SMCO

  2. #2
    Join Date
    Jun 2002
    Location
    Mpls/St.Paul area
    Posts
    303
    Are you trying to set the visibility of an object in the subreport based on a calculation that occurs in the report? At that point it may be too late.

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Code:
         Dim subRpt As Report
        Dim MyObject As Object
        Dim rptVal As String
        
        Set rptSub = Report_8STEP_SEC3C_SUB_subreport_2.Expr1
        Set MyObject = rptSub
    Spot the difference?

    Have you set up option explicit?

  4. #4
    Join Date
    Jun 2002
    Location
    Mpls/St.Paul area
    Posts
    303
    Are you trying to set the visibility of an object in the subreport based on a calculation that occurs in the report? At that point it may be too late.

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    I believe jp is correct - but there are other errors there too by the look of it.

  6. #6
    Join Date
    Aug 2007
    Posts
    25
    Quote Originally Posted by pootle flump
    Code:
         Dim subRpt As Report
        Dim MyObject As Object
        Dim rptVal As String
        
        Set rptSub = Report_8STEP_SEC3C_SUB_subreport_2.Expr1
        Set MyObject = rptSub
    Spot the difference?

    Have you set up option explicit?
    I have the object properly labeled in the report. I transposed it when I entered it here. I should have copied and pasted.
    Kirk Wahl
    GM Powertrain SMCO

  7. #7
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Oh lordy - always copy and paste code exactly what you are using.

    So we don't know what your code is but know it errors? In that case jp's suggestion is your best shot. We can't help if we are looking at an approximation of the senario that is causing the errors.

Posting Permissions

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