problem with Datareport please help me iam final stage in my project

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pramodrepaka
    New Member
    • Mar 2007
    • 21

    problem with Datareport please help me iam final stage in my project

    hi this is pramod i am facing a small problem
    Code:
    Private Sub Command_Click()
    Dim a As String
    
    a = InputBox("enter empno")
    
    If rs.State = 1 Then rs.Close
    
    rs.Open "select * from microbiology Where bat_num = " & a, cn, adOpenForwardOnly, adLockReadOnly
    
    LinkDataReport1
    
    end sub
    
    Public Sub LinkDataReport1()
    
    With DataReport2
    
        'We must set The DataReport source to nothing!
        'Else DataReport wants to use its own Source
        Set .DataSource = Nothing
        .DataMember = ""
        
            'We Connect the DataReport to our Recordset Since
            'we disallowed DataReport1 to use its own above
            Set .DataSource = rs
                    
            'Here we are 'Hard Coding the textboxs to the fields
            With .Sections("Section1").Controls
                .Item(1).DataMember = ""
                .Item(1).DataField = rs.Fields(0).Name
                .Item(2).DataMember = ""
                .Item(2).DataField = rs.Fields(1).Name
                .Item(3).DataMember = ""
                .Item(3).DataField = rs.Fields(2).Name
                .Item(4).DataMember = ""
                .Item(4).DataField = rs.Fields(3).Name
                .Item(5).DataMember = ""
                .Item(5).DataField = rs.Fields(4).Name
           End With
                   
        .Show
    
    End With
    
    End Sub
    In the above code i am getting a RUNTIME Error i.e

    Object does not support this property or method

    while in the above code when iam using with datareport1 i am not getting error
    what is the problem i am not able to understand please help if any can
    Last edited by Killer42; Apr 26 '07, 07:33 AM. Reason: Please use [CODE]...[/CODE] tags around your code.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Do you know which line produces the error?

    Comment

    • pramodrepaka
      New Member
      • Mar 2007
      • 21

      #3
      Originally posted by Killer42
      Do you know which line produces the error?

      .Item(1).DataMe mber = ""
      .Item(1).DataFi eld = rs.Fields(0).Na me

      error: object doesn't support this property or method

      Comment

      • Dököll
        Recognized Expert Top Contributor
        • Nov 2006
        • 2379

        #4
        Originally posted by pramodrepaka
        .Item(1).DataMe mber = ""
        .Item(1).DataFi eld = rs.Fields(0).Na me

        error: object doesn't support this property or method
        Hey there, pramodrepaka!

        Looks like you dimensioned a, but you did not do the same for rs. Your problem may be more specific. Also, run your code in debug mode to see what it is doing:

        (1) Choose Debug
        (2) Step Into
        (3) Hit F8 until you each the error pop up

        I will plug in your code see what it does here...

        Comment

        • Dököll
          Recognized Expert Top Contributor
          • Nov 2006
          • 2379

          #5
          Originally posted by pramodrepaka
          .Item(1).DataMe mber = ""
          .Item(1).DataFi eld = rs.Fields(0).Na me

          error: object doesn't support this property or method
          Hey there, pramodrepaka!

          Looks like you dimensioned a, but you did not do the same for rs. Your problem may be more specific. Also, run your code in debug mode to see what it is doing:

          (1) Choose Debug
          (2) Step Into
          (3) Hit F8 until you each the error pop up

          I will plug in your code see what it does here...

          Comment

          • pramodrepaka
            New Member
            • Mar 2007
            • 21

            #6
            hey
            i tried what u said but i am not able to solve the problem i,e the error is
            .Item(1).DataMe mber = ""
            .Item(1).DataFi eld = rs.Fields(0).Na me


            the error number is 438
            and the error message is
            object doesn't support this prorperty or method
            what 2 do i am not able 2 understand plz help me
            Originally posted by Dököll
            Hey there, pramodrepaka!

            Looks like you dimensioned a, but you did not do the same for rs. Your problem may be more specific. Also, run your code in debug mode to see what it is doing:

            (1) Choose Debug
            (2) Step Into
            (3) Hit F8 until you each the error pop up

            I will plug in your code see what it does here...

            Comment

            • Killer42
              Recognized Expert Expert
              • Oct 2006
              • 8429

              #7
              Originally posted by pramodrepaka
              .Item(1).DataMe mber = ""
              .Item(1).DataFi eld = rs.Fields(0).Na me
              There are two lines there. We still don't know which one produces the error. Which also means that we don't know whether the error refers to .Item(1) or rs.Fields(0).

              You need to be more specific.

              Comment

              Working...