Requery不会更新组合框MS Access 2010

时间:2017-10-10 20:39:08

标签: access-vba

我有一个带有组合框和子表单的未绑定表单。当我删除此表单上的记录时,组合框不会刷新,除非我完全关闭它并再次打开它。甚至尝试通过将行源设置为""来手动刷新组合框。然后回到查询。仍然没有运气。

这是我的删除代码:

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

1 个答案:

答案 0 :(得分:0)

如果未绑定,您还必须设置其值:

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