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 |
#13
|
|||
|
|||
david epsom dot com dot au wrote:
I don't have that problem with this in Access 2000: Private Sub Form_Current() MsgBox Me.Recordset Is Nothing End Sub Private Sub Form_Open(Cancel As Integer) MsgBox Me.Recordset Is Nothing End Sub Both msgbox show 'True' I don't have any problem with "Me.Recordset Is Nothing" either. What I am trying to say is that a check of "Me.Recordset Is Nothing" - which works perfectly - causes a runtime error when the form is closed. If you don't believe please open the database I attached to my posting yesterday. Meanwhile I tested this database on another computer with Access 2002, and I get the runtime error again (I can't test it in Access 2000 as I don't have this version at hand). As a "Me.Recordset Is Nothing" check in Form_Current() shouldn't cause a runtime error when the form is closed I believe this is a bug in Access. The work-around would be to ignore runtime error 3021 but then I should file a bug report to Microsoft at least. I am trying to track down the bug some more but would appreciate any help. Please open the test database, open the main form, click on the button and then close the main form. If you get a runtime error you see what I mean. :-) Boris "Boris" wrote in message ... 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 |