View Single Post
  #14  
Old August 19th, 2004, 12:42 PM
Brendan Reynolds
external usenet poster
 
Posts: n/a
Default

Well, you've got my curiositly going now! So I tried changing the code
behind the command button as follows, (I've left the original ADO code in
there, but commented out) and sure enough the error disappears ...

Private Sub cmdButton_Click()
'Dim adoCmd As New ADODB.Command

'adoCmd.ActiveConnection = CurrentProject.Connection
'adoCmd.CommandType = adCmdText

'adoCmd.CommandText = "INSERT INTO tblB ([ID], [fkA]) VALUES(1, 1)"
'adoCmd.Execute Options:=adExecuteNoRecords
CurrentDb.Execute "INSERT INTO tblB (ID, fkA) VALUES (1, 1)",
dbFailOnError
Me![subform].Requery

'adoCmd.CommandText = "DELETE FROM tblB WHERE [ID] = 1"
'adoCmd.Execute Options:=adExecuteNoRecords
CurrentDb.Execute "DELETE FROM tblB WHERE ID = 1", dbFailOnError
Me![subform].Requery
End Sub

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.


"Boris" wrote in message
...
Brendan Reynolds wrote:
I wouldn't usually do this, but curiosity got the better of me, and I
took a look at the MDB you posted. I noticed that the error doesn't
occur if I open and close the form without clicking the command
button. It occurs only after clicking the button, the code behind
which writes a record to a table and then deletes that same record.
This leads me to suspect that we're seeing some kind of timing or
caching problem. If this were DAO, I'd be thinking about putting in a
couple of DbEngine.Idle statements, one after the line that writes
the record and another after the line that deletes it. But I don't
know what, if anything, the ADO equivalent of DbEngine.Idle might be?


Hi, thanks for jumping into the thread! I will rewrite the code using DAO.
Maybe this is an ADO problem. I will be back soon.

Boris

[...]