【发布时间】:2022-03-31 23:53:53
【问题描述】:
我有一个带有组合框和子表单的未绑定表单。当我删除此表单上的记录时,组合框不会刷新,除非我完全关闭它并再次打开它。甚至尝试通过将行源设置为“”然后返回查询来手动刷新组合框。仍然没有运气。
这是我的删除代码:
Sub DeleteFS(iID As Integer)
Dim strSQL As String
Dim strSQLAmend As String
Dim strDocNum As String
strDocNum = DLookup("DocumentNumber", "tblFS", "ID=" & iID)
strSQL = "DELETE * FROM tblFS WHERE ID=" & iID
strSQLAmend = "DELETE * FROM tblAcquisitionAMD " _
& "WHERE (((Acq_ID) Like '* FS' Or (Acq_ID) Is Null) AND ((FS_ID)=" & iID & "));"
If MsgBox("As long as there are no associated Acquisition ID's - THIS and all related amendments will be deleted.", vbYesNo + vbInformation, "Are you sure?") = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.RunSQL strSQLAmend
DoCmd.SetWarnings True
'attempt to manually requery the combobox
Me.cboDocumentSearch.RowSource = ""
Me.cboDocumentSearch.RowSource = "qFS_ParentSearch"
MsgBox "This instance of Document Number: " & strDocNum & " has been successfully deleted."
End If
【问题讨论】:
-
Me.cboDocumentSearch.Requery怎么样? (最明显的选择,但我在你的代码中没有看到) -
是的。这就是我首先尝试的。我似乎总是通过手动重新查询成功,但在这里也不起作用。