访问VBA从一个列表框移动到另一个列表框

时间:2018-04-11 08:31:29

标签: ms-access access-vba ms-access-2010 ms-access-2007 ms-access-2013

我有一个名为lstAvailable的列表框,我正在将选中的项目移动到名为lstAssigned的另一个列表框中,此处发送的值也存储在表tblComponents中。值存储在表中但我无法在列表框lstAssigned中看到移动的项目。有人能帮助我吗?

守则

nRid = listMachineSubSystem.Column(1)
For Each varRow In lstAvailable.ItemsSelected
nEid = lstAvailable.Column(0, varRow)
    sSQL = "INSERT INTO tblComponents ([Machine Subsystem ID], [NewComponents])" _
    & " VALUES (" & nRid & ", " & nEid & ");"

    CurrentDb.Execute sSQL, dbFailOnError
    Next varRow
    lstAvailable.Requery
    lstAssigned.Requery
    For Each varItem In lstAvailable.ItemsSelected
        lstAvailable.Selected(varItem) = False
    Next
    For Each varItem In lstAssigned.ItemsSelected
        lstAssigned.Selected(varItem) = False
    Next
 End Sub

0 个答案:

没有答案