Requery不会更新组合框MS Access 2010

问题描述:

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

这里是我的删除代码:

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 
+0

什么'Me.cboDocumentSearch.Requery'? (最明显的选择,但我没看到它在你的代码中) –

+0

是的。这是我第一次尝试。我似乎总是用手工查询获得成功,但它在这里也不工作。 – monty327

如果是未绑定的,你还必须将其值设置:

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