B
Boris
It took me some hours to track this bug so I hope someone can help or
confirm that this is a bug in Microsoft Access (I use Access 2003). My
database is able to create runtime error 3021 with an empty "If Me.RecordSet
Is Nothing Then" clause. The whole database consists of two tables, two
forms and two short VBA subs. The description of the database follows. If
someone wants to get my database (170 KByte unzipped) please send an e-mail
to boris @ highscore . de (remove spaces) - I don't know if it is
appreciated if databases are sent to these newsgroups.
Okay, I have two simple tables tblA and tblB:
tblA: ID (primary key, long integer)
tblB: ID (primary key, long integer), fkA (long integer, "foreign key" for
tblA)
Add a record to tblA with ID 1.
Then there are two simple forms frmMain and fsubEmbedded:
frmMain: unbound, one subform (fsubEmbedded), one button (cmdButton)
fsubEmbedded: bound ("SELECT tblA.ID FROM tblA, tblB WHERE tblA.ID=tblB.fkA
AND tblB.ID=1"), one text control (bound to tblA.ID)
When you click on the button in frmMain this VBA code is called (I use ADO
so you may need to set a reference to that library):
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
Me![subform].Requery
adoCmd.CommandText = "DELETE FROM tblB WHERE [ID] = 1"
adoCmd.Execute Options:=adExecuteNoRecords
Me![subform].Requery
End Sub
Everything works perfectly until you add this VBA code to fsubEmbedded:
Private Sub Form_Current()
If Me.Recordset Is Nothing Then
End If
End Sub
Open frmMain, click on the button, close the form - voila, runtime error
3021.
Of course this is the stripped down version of another much bigger database.
So a solution like "don't use that if-then-clause" doesn't help me. If
someone knows what exactly causes this runtime error 3021 I might find a
solution in my database how to prevent it.
Thanks in advance for any ideas,
Boris
confirm that this is a bug in Microsoft Access (I use Access 2003). My
database is able to create runtime error 3021 with an empty "If Me.RecordSet
Is Nothing Then" clause. The whole database consists of two tables, two
forms and two short VBA subs. The description of the database follows. If
someone wants to get my database (170 KByte unzipped) please send an e-mail
to boris @ highscore . de (remove spaces) - I don't know if it is
appreciated if databases are sent to these newsgroups.
Okay, I have two simple tables tblA and tblB:
tblA: ID (primary key, long integer)
tblB: ID (primary key, long integer), fkA (long integer, "foreign key" for
tblA)
Add a record to tblA with ID 1.
Then there are two simple forms frmMain and fsubEmbedded:
frmMain: unbound, one subform (fsubEmbedded), one button (cmdButton)
fsubEmbedded: bound ("SELECT tblA.ID FROM tblA, tblB WHERE tblA.ID=tblB.fkA
AND tblB.ID=1"), one text control (bound to tblA.ID)
When you click on the button in frmMain this VBA code is called (I use ADO
so you may need to set a reference to that library):
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
Me![subform].Requery
adoCmd.CommandText = "DELETE FROM tblB WHERE [ID] = 1"
adoCmd.Execute Options:=adExecuteNoRecords
Me![subform].Requery
End Sub
Everything works perfectly until you add this VBA code to fsubEmbedded:
Private Sub Form_Current()
If Me.Recordset Is Nothing Then
End If
End Sub
Open frmMain, click on the button, close the form - voila, runtime error
3021.
Of course this is the stripped down version of another much bigger database.
So a solution like "don't use that if-then-clause" doesn't help me. If
someone knows what exactly causes this runtime error 3021 I might find a
solution in my database how to prevent it.
Thanks in advance for any ideas,
Boris