updated records are displayed as #deleted#

M

Mark Kubicki

I've got a command button on a form which clears all of the current entries
in a table, and then adds a default set of entries (from another table)...

Generally, it works fine, but sometimes (I haven't found a pattern yet) the
displayed data is a form full of records marked #deleted# (an no other
records behind those). If I click the button again. All of the correct
entries are displayed. (closing and reopening does not clear the #deleted#
problem)

the (edited) code behind the button is:

Private Sub restorestandrd_Click()
Call DoSQLDeleteProjectNotes(Me)
Call DoSQLAddProjectNotes(Me)
Me.Requery
Me.Refresh
End Sub

----------------------
Public Sub DoSQLDeleteProjectNotes(frm As Access.Form)
Dim sSQL As String
sSQL = "Delete * from Notes"

DoCmd.SetWarnings False
DoCmd.RunSQL sSQL
DoCmd.SetWarnings True
End Sub

----------------------
Public Sub DoSQLAddProjectNotes(frm As Access.Form)
Dim sSQL As String
sSQL = "INSERT INTO Notes(PrintNote, optionNumber, Options) " & _
"SELECT OptionRequired, null, Options " & _
"from optNotes " & _
"WHERE OptionRequired = True ;"

DoCmd.SetWarnings False
DoCmd.RunSQL sSQL
DoCmd.SetWarnings True
End Sub
 
K

Klatuu

Probably a timing issue since sometimes it works and sometimes it doesn't.

Try this:
First, change these lines in your functions:
DoCmd.RunSQL sSQL

To
Currentdb.Execute(sSQL), dbFailOnError

It is faster and you can remove the setwarnings lines.
The Execute method goes directly to Jet, so it doesn't trigger warnings.

Then here is a link to some code you can use to pause execution for a period
of time to allow the queries to complete. Put it just before the Me.Requery
http://www.mvps.org/access/api/api0021.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top