Dim rs As ADODB.Recordset 自定义变量类型未定义的错误如何解决?
PrivateSubCommandButton1_Click()Application.ScreenUpdating=FalseRows("6:6").SelectRan...
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Rows("6:6").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim sql As String
Dim Conn1 As New ADODB.Connection
Dim i As Integer
sql = "select * from TBL_Order"
Call RELDB(sql, rs, Conn1)
If Not rs.BOF Then rs.MoveFirst
i = 6
While Not rs.EOF
Cells(i, 1) = rs!OrderID
Cells(i, 2) = rs!CustomerID
Cells(i, 3) = rs!OrderDate
Cells(i, 4) = rs!OrderNum
Cells(i, 5) = rs!StatusOrder
Cells(i, 6) = rs!TestConditionID
Cells(i, 7) = rs!TestMethodID
Cells(i, 8) = rs!TotalCompressorNum
Cells(i, 9) = rs!FinishedCompressorNum
Cells(i, 10) = rs!UntestedCompressorNum
rs.MoveNext
i = i + 1
Wend
Cells(6, 1).Select
Application.ScreenUpdating = True
End Sub 展开
Application.ScreenUpdating = False
Rows("6:6").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim sql As String
Dim Conn1 As New ADODB.Connection
Dim i As Integer
sql = "select * from TBL_Order"
Call RELDB(sql, rs, Conn1)
If Not rs.BOF Then rs.MoveFirst
i = 6
While Not rs.EOF
Cells(i, 1) = rs!OrderID
Cells(i, 2) = rs!CustomerID
Cells(i, 3) = rs!OrderDate
Cells(i, 4) = rs!OrderNum
Cells(i, 5) = rs!StatusOrder
Cells(i, 6) = rs!TestConditionID
Cells(i, 7) = rs!TestMethodID
Cells(i, 8) = rs!TotalCompressorNum
Cells(i, 9) = rs!FinishedCompressorNum
Cells(i, 10) = rs!UntestedCompressorNum
rs.MoveNext
i = i + 1
Wend
Cells(6, 1).Select
Application.ScreenUpdating = True
End Sub 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询