对象打开时不允许操作解决方法

对象打开时不允许操作
对象打开时不允许操作解决方法
Dim rs As New ADODB.Recordset
Dim rs1 As New ADODB.Recordset

Dim i As Integer, j As Integer
'Public Function cnn() As ADODB.Connection    '定义函数
  'Set cnn = New ADODB.Connection
  '返回一个数据库连接
  'cnn.Open "rovider=SQLOLEDB.1ersist Security Info=true;User ID=sa;pwd=eisoft;Initial Catalog=LF_DB;data source=ERPSERVER"

'End Function

Private Sub flex1_DblClick()
MSHFlexGridEdit flex1, txtEdit, 32
End Sub

Private Sub flex1_KeyPress(KeyAscii As Integer)
MSHFlexGridEdit flex1, txtEdit, KeyAscii
End Sub


Private Sub Form_Load()
Adodc1.ConnectionString = PublicStr
Adodc1.RecordSource = "select * from qcr"
Adodc1.Refresh

  Dim i As Integer
  '使第一列较窄。
  flex1.ColWidth(0) = flex1.ColWidth(0) / 2
  '初始化编辑框
  txtEdit = ""
  flex1.Rows = 2
  flex1.Cols = 8
  '设置列标头。
  s$ = "序号|^条码号                    |^工程号       |^图档号      |^板号        |^验退数量 |^验退部门    |^备注       |^ 制程        "
  flex1.FormatString = s$
End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)

Select Case Button.Key

   Case "new"
Dim lsph As Integer     '声明一个整型变量
  
    rs.Open "select * from qcr order by dh", cnn, adOpenStatic
    If rs.RecordCount > 0 Then
    If Not rs.EOF Then rs.MoveLast
    If rs.Fields("dh") <> "" Then
       lsph = Val(Right(Trim(rs.Fields("dh")), 4)) + 1
       Text1.Text = Format(Date, "yyyymmdd") & Format(lsph, "0000")
     End If
    Else
    Text1.Text = Format(Date, "yyyymmdd") & "0001"