有没有办法永久删除列表框中的项目(所以在重新打开userform之后这个项目仍然没有消失)? 我正在使用ADO。 这是我将项目添加到列表框的代码:
cnn.Open "Provider=Microsoft.ACE.OLEDB.12.0;;" & _
"Data Source=C:\Users\plkmxm08\Desktop\MMS.xlsm;" & _
"Extended Properties=""Excel 12.0 Xml;HDR=YES;"";"
rst.Open "SELECT [LINE], [TASK], [Frequency], qqq.[IdTask] FROM qqq ORDER BY [LINE];", _
cnn, adOpenStatic
With Me.ListBox1
.Clear
.ListStyle = fmListStyleOption
Do
.AddItem
.List(i, 0) = rst![Line]
.List(i, 1) = rst![Task]
i = i + 1
rst.MoveNext
Loop Until rst.EOF
End With
以下是删除项目表单列表框的代码:
cnn.Open "Provider=Microsoft.ACE.OLEDB.12.0;;" & _
"Data Source=C:\Users\plkmxm08\Desktop\MMS.xlsm;" & _
"Extended Properties=""Excel 12.0 Xml;HDR=YES;"";"
rst.Open "SELECT [LINE], [TASK], [Frequency], qqq.[IdTask] FROM qqq LEFT JOIN dane_
ON qqq.[IdTask] = dane.[IdTask];", _
cnn, adOpenKeyset, adLockOptimistic, adCmdTableDirect
If bSelected = True Then
For lItem = 0 To lRows
If ListBox1.Selected(lItem) = True Then
cnn.Execute "INSERT INTO dane([IdTask],[Date]) SELECT [IdTask], [Teraz] _
FROM qqq WHERE Line= '" & Me.ListBox1.List(lItem, 0) & "' _
And Task = '" & Me.ListBox1.List(lItem, 1) & "'"
MsgBox "Zapisane zostało mycie - " & ListBox1.List(lItem, 1) & _
" na linii " & ListBox1.List(lItem, 0), vbInformation
ListBox1.RemoveItem (ListBox1.ListIndex)
End If
我想写一个循环,检查是否在表“dane”(在我的表格中的不同excel文件中)有该项目的ID号但是因为我是ADO的新手我有这个问题