所以我有这个简单的代码循环通过附加到表的列表框。它在列表框中找到所选项目并更新我的“操作日志”表中的相应记录集。我的问题是,即使它说lstAllGroups.Column(1, i)
是持有正确的价值;它没有更新记录。我已经在调试器中介绍了这一点,它添加了一切,但groupNum。VBA记录不会更新正确的信息
Dim recPicker As String
Dim recAllPicker As String
Set db = CurrentDb
Set RstRecSet = db.OpenRecordset("tblActionLog", dbOpenDynaset)
'Set RstRecSet = db.OpenRecordset("Select * from tblActionLog Where GroupNum = '" & recAllPicker & "';", dbOpenDynaset)
If chkGrp = True Then
allGrps = lstAllGroups.ListCount
For i = 0 To allGrps
If lstAllGroups.Selected(i) = True Then
recAllPicker = lstAllGroups.Column(1, i)
RstRecSet.AddNew
RstRecSet("GroupNum").Value = lstAllGroups.Column(1, i)
RstRecSet("GroupName").Value = lstAllGroups.Column(0, i)
RstRecSet("ActionItem").Value = txtActionitm.Value
RstRecSet("GroupNum").Value = recPicker
RstRecSet("DateClosed").Value = txtDateClosed.Value
RstRecSet("DateIdentified").Value = txtDateID.Value
RstRecSet("Analyst").Value = txtAnalyst.Value
RstRecSet("Comments").Value = txtComments.Value
RstRecSet.Update
End If
Next
Else
嘿HansUp,对不起,如果我不清楚。除了groupnum之外,GroupName还会添加一个问题。 GroupName是我的列表框中的第一个列,GroupNum是第二个列。 – SaladSnake 2014-11-14 18:23:55
仍然不知道我明白。你是说每一行添加到* tblActionLog *为* GroupNum *为空? – HansUp 2014-11-14 18:27:52
是的,我停止了调试器,它显示lstAllGroups.Column(1,i)保持正确的值,它只是没有插入到具有该值的记录,而是它为空。奇怪的是每隔一个更新都没有问题。 – SaladSnake 2014-11-14 18:31:26