Question : Access 2007 accdb form - Close Form button event causes #Deleted in fields, yet record is NOT deleted

I am converting an Access XP application to Access 2007 Front End/SQL Server backend.  One Access form has a temporary table exclusively as it's recordset.  When the doCmd.Close event is fired, the form flashes open with #deleted in all the fields even though the record is NOT deleted in the underlying table.  Has anyone seen this before?

Answer : Access 2007 accdb form - Close Form button event causes #Deleted in fields, yet record is NOT deleted

And the code on the close event of this form is....?

1. Try Hiding the form first.
    Me.visible=False
    DoCmd.Close acForm, "subxpaytemp"

2. Or hide the controls
Dim ctl as Control
    For each ctl in me.controls
        ctl.visible=False
    next ctl
    DoCmd.Close acForm, "subxpaytemp"

3. Or instead of deleting the records, delete the entire table

    CurrentDB.execute "Drop Table YourTable",dbfailonError
    DoCmd.Close acForm, "subxpaytemp"

...then recreate and load it when the form opens

4. Or move the "Delete" code to the code that "Opens" the form.
(So before the form is opened the old data is delete and the new data is added)

5. Or set the Forecolor (Fontcolor) to white...

...I'm sure you get the idea.
Basically you want to do whatever you can so the #Deleted never has a chance to display.

;-)

JeffCoachman
Random Solutions  
 
programming4us programming4us