run time error '6160' data access error ??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hwkong1688
    New Member
    • Dec 2011
    • 7

    #1

    run time error '6160' data access error ??

    Hi all,
    why got this error message when run the program??
    anyone help is much appreciated.

    Line 28 error.

    Code:
    Private Sub Prn2_Click()
    
    Dim RRow2 As Integer
    Dim Colomn2 As Integer
    
    DataGrid1.Row = 0
    DataGrid1.Col = Colomn2
    For Colomn2 = 0 To DataGrid1.Columns.Count - 1
    DataGrid1.Col = Colomn2
    Debug.Print DataGrid1.Text
    
    Next
    
    RRow2 = 0
    Colomn2 = 0
    DataGrid1.Col = Colomn2
    DataGrid1.Row = RRow2
    
    If MsgBox("           Print to all?", vbOKCancel, "Print") = vbCancel Then
    Exit Sub
    End If
    
    For RRow2 = 0 To rs2.RecordCount - 1
    
            For Colomn2 = 0 To DataGrid1.Columns.Count - 1
                DataGrid1.Col = Colomn2
            Next
            Text2.Text = DataGrid1.Text    'this line got error    
            
            LabelFormat2
              
            rs2.MoveNext        
     Next
            Printer.EndDoc
    End Sub
    Code:
    Public Sub LabelFormat2()
    
    Printer.Print "{D0391,0919,0360|}"
    Printer.Print "{C|}"
    Printer.Print "{D0391,0919,0360|}"
    Printer.Print "{AX;+000,+000,+00|}"
    Printer.Print "{AY;+00,0|}"
    Printer.Print "{PC000;0136,0162,20,25,K,00,B|}"
    Printer.Print "{RC00;" & Text2.Text & "|}"
    Printer.Print "{XB00;0210,0200,A,3,03,0,0144,+0000000000,000,0,00|}"
    Printer.Print "{RB00;>5>8>6" & Text2.Text & "|}"
    Printer.Print "{XS;I,0001,0002C6200|}"
    
    Printer.EndDoc
    
    End Sub
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    What line is the error on?

    Comment

    • hwkong1688
      New Member
      • Dec 2011
      • 7

      #3
      Run time error '6160' data access error

      Code:
      Text2.Text = DataGrid1.Text    'this line got error

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        The DataGrid.Text property is not meaningful. It's not supposed to be used for anything.

        Comment

        • hwkong1688
          New Member
          • Dec 2011
          • 7

          #5
          but how to set value from datagrid1.text to my text1.text?

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            Datagrid.text has no value. You shouldn't ever want to use it for anything. Why you want to use it perplexes me. You must be trying to do something else and think you need to use datagrid.text but I have no idea what you're trying to do because you haven't said.

            Comment

            • Killer42
              Recognized Expert Expert
              • Oct 2006
              • 8429

              #7
              According to my research, there are a number of ways to access the data in a DataGrid control. One way is via the the .Text property of the DataGrid object which provides the (formatted) value of the current cell. Another is via the .Value property of the Column object. Please review the documentation for the DataGrid control, which will no doubt include samples.

              I'd provide pointers to the relevant doco at MSDN, but for some reason trying to look something up there does a search of the entire web instead.

              However, the runtime error 6160 is most likely caused by there being no data in the recordset. Try hitting Google for something like "runtime error 6160" and you'll find all sort of info.

              Oh, one other thing. Are you aware that your Colomn2 loop doesn't do anything? My guess is that it should include the printing.

              Comment

              Working...