1
votes

I have an unbound form with a combo box and a subform. When I delete records on this form the combo box does not refresh unless I completely close it and open it again. Even tried manually refreshing the combo box by setting the row source to "" then back to the query. Still no luck.

Here is my delete code:

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
What about Me.cboDocumentSearch.Requery? (The most obvious choice, but I don't see it in your code)Erik A
Yes. That's what I tried first. I always seem to succeed with the manual requery, but it's not working here either.plateriot

1 Answers

0
votes

If it is unbound, you must also set its value:

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