If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Bug: Empty "If Me.Recordset Is Nothing Then" clause causes runtime error 3021 (Access 2003)
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 |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Useless Access 2003 | tired, angry, sucidial and bored | General Discussion | 10 | July 21st, 2004 11:52 PM |
Access 2003 Runtime Issue | IraKeener | General Discussion | 0 | June 30th, 2004 08:42 PM |
Access 2003 | RK | General Discussion | 12 | June 14th, 2004 10:16 AM |
Problem running Access 2003 and Access 2000 apps on same machine. | Rathtap | General Discussion | 3 | June 13th, 2004 01:30 AM |
Productkey problem when installing office 2003 on network | Stefan Schreurs | Setup, Installing & Configuration | 1 | June 1st, 2004 11:16 PM |