【问题标题】:Requery does not update a combo box MS Access 2010重新查询不更新组合框 MS Access 2010
【发布时间】: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 怎么样? (最明显的选择,但我在你的代码中没有看到)
  • 是的。这就是我首先尝试的。我似乎总是通过手动重新查询成功,但在这里也不起作用。

标签: ms-access vba


【解决方案1】:

如果是未绑定的,还必须设置它的值:

Me!cboDocumentSearch.Requery
Me!cboDocumentSearch.Value = Null

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-01
    • 2019-01-01
    • 2011-01-04
    • 2013-05-17
    • 1970-01-01
    相关资源
    最近更新 更多