使用VBA时键入不匹配错误

时间:2018-04-25 15:03:17

标签: vba

我正在使用VBA,运行附加代码时出错,它表示类型不匹配。

有人可以帮助我找到错误吗? 请

Private Sub List1_DblClick()        
    Dim val As String
    Dim val2 As String
    Dim i As Integer

    Dim rs As ADODB.Recordset

    Set GSBMconn = New ADODB.Connection

    'Set rs = New ADODB.Recordset

    For i = 0 To List1.ListCount - 1
        If List1.Selected(i) Then
            val = List1.List(i)

            Debug.Print (val)
            Set rs = Grid.DataSource

            rs.AddNew        

            Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=cmd\cmd.mdb;Persist Security Info=False;Jet OLEDB:Database Password="

            With Adodc1
                .RecordSource = "SELECT *" & _
                                "FROM StockLevel3 " & _
                                "WHERE ItemName = '" & val & "'; "
            End With

            Set Grid.DataSource = Adodc1

            Adodc1.Refresh
        End If
    Next
End Sub

0 个答案:

没有答案