2017-10-10 67 views
0

我有一個帶有組合框和子窗體的未綁定窗體。當我刪除此表單上的記錄時,組合框不會刷新,除非我完全關閉並再次打開它。甚至嘗試通過將行源設置爲「」然後返回到查詢手動刷新組合框。仍然沒有運氣。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

回答

0

如果是未綁定的,你還必須將其值設置:

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