Error # 3021 Was Generated By Adodb.field
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Code is OK in DAO but gives run-time error '3021' in ADO up vote 2 down vote favorite This occurs after replacing DAO with ADO in a VB6 project that uses an Access 97 database. It occurs on the line marked 'Error Here in the following snippet: If rset.BOF <> True Or rset.EOF <> True Then rset.MoveLast Do While rset.BOF <> True rset.Delete If rset.BOF <> True Or rset.EOF <> True Then rset.MoveLast 'Error Here End If Loop End If Run-time error '3021' gves this explanation : "Either EOF or BOF is True, or the current record has been deleted. requested operation requires a current record." It appears that after the last record in the recordset is deleted BOF +/- EOF is still false in the ADO version of the code while both are true in the DAO version. If I alter the code like this it works EDIT : the following code does NOT work. When I tried this 'solution' all the records were already deleted from the table, therefore the entire block was bypassed and so no error was thrown. Sorry for the bad information. If rset.BOF <> True Or rset.EOF <> True Then rset.MoveLast Do While rset.BOF <> True rset.Delete If rset.BOF <> True Or rset.EOF <> True Then End If If rset.BOF <> True Or rset.EOF <> True Then rset.MoveLast End If Loop End If Can someone explain this? (and ideally offer a solution that does not involve changing code !) FURTHER EDIT : As far as I can tell having tried lots of ways, the BOF and EOF are useless in ADO for testing for an empty recordset after a delete. This is because you need to use one of the move methods to update the BOF/EOF and if the recordset is empty you'll get an error. On the recordset I used, the RecordCount property was updated after a delete. Although I am not going to use it, this code did work : If rset.BOF <> True Or rset.EOF <> True Then Do While rset.RecordCount > 0 rset.MoveLast rset.Delete Loop End If Edit ( 1 month later) So after rewriting a w
Question Need help? Post your question and get tips & solutions from a community of 418,502 IT Pros & Developers. It's quick & easy. How do I Avoid Error 3021: No Current Record P: 2 psdsen Please help me for the following program problem. When I Click Next button, at the last record, it Shows --Run time error '3021': Either BOF or EOF...... Expand|Select|Wrap|Line Numbers OptionExplicit DimstrsqlAsString Dimcon_dataAsADODB.Connection Dimrs_DataAsADODB.Recordset PrivateSubForm_Load() Setcon_data=NewADODB.Connection Setrs_Data=NewADODB.Recordset con_data.Provider="Microsoft.jet.oledb.4.0;DataSource="&App.Path&"\salary97.mdb" con_data.Open strsql=("select*fromemployee") rs_Data.Openstrsql,con_data,adOpenDynamic,adLockOptimistic EndSub PrivateSubcmdnext_Click() Ifrs_Data.EOFThen rs_Data.MoveLast http://stackoverflow.com/questions/5995071/code-is-ok-in-dao-but-gives-run-time-error-3021-in-ado Else rs_Data.MoveNext EndIf txtnm.Text=rs_Data!ename EndSub Oct 22 '11 #1 Post Reply Share this Question 5 Replies Expert Mod 2.5K+ P: 2,543 Stewart Ross The error message is quite correct (although you have not posted all of it, just the start of it!). When you are already at the end of file position (in your case when rs_Data.EOF is true) you have gone past https://bytes.com/topic/access/answers/920315-how-do-i-avoid-error-3021-no-current-record all active records, so you cannot execute a move to the last record. If you really want the last record to be the one displayed at end of file you will need to execute rs_Data.MoveFirst immediately before executing rs_Data.MoveLast. However, if there are no records at all in the table the MoveFirst will also fail with the same error message. This is where testing for both EOF and BOF being true at the same time comes in - both conditions are true simultaneously if the recordset is empty. -Stewart Oct 22 '11 #2 reply Expert Mod 15k+ P: 29,922 NeoPa Please read When Posting (VBA or SQL) Code before posting again. Oct 22 '11 #3 reply Expert 5K+ P: 8,405 ADezii This actually a little tricky since this Type of Recordset does not support the AbsolutePosition Property, and will also not give a valid RecordCount. What you can do is to Trap specific Errors, such as 3021, then move the Pointer to the Last Record and Update the Text Box: Expand|Select|Wrap|Line Numbers PrivateSubcmdNext_Click() OnErrorGoToErr_cmdNext rs_Data.MoveNext Me!txtnm=rs_Data!ename Exit_cmdNext: ExitSub Err_cmdNext: SelectCaseErr.Number Case3021,2113 rs_Data.MoveLast Me!txtnm=txtnm.Te
for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Ask a Question Ask for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Expand https://www.experts-exchange.com/questions/23563695/ADO-VB6-Error-3021-Even-with-1-record-in-recordset.html Search Submit Close Search Login Join Today Products BackProducts Gigs Live Careers Vendor Services Groups http://forum.productcart.com/either-bof-or-eof-is-trueerror-3021_topic6082.html Website Testing Store Headlines Experts Exchange > Questions > ADO VB6 Error 3021; Even with 1 record in recordset? Want to Advertise Here? Solved ADO VB6 Error 3021; Even with 1 record in recordset? Posted on 2008-07-14 Visual Basic Classic 1 Verified Solution 18 Comments 877 Views Last Modified: 2013-12-25 VB6 and Access using ADO to manipulate records. error # In a select statement I am tyring to retrieve 1 record. BOF and EOF = true and therefore I get error 3021. However if I insert a message box the record pointer works and no 3021 error is generated. I don't want the msgbox code in the program. How can I get the 3021 error to go away? 0 Question by:kbios Facebook Twitter LinkedIn Google LVL 142 Active today Best Solution byGuy Hengel error # 3021 [angelIII / a3] does the code, just before the select, perform the insert of the row? the only thing I remember is that access does have a delay for new rows to be available over odbc/oledb... Go to Solution 18 Comments LVL 142 Overall: Level 142 Visual Basic Classic 32 Message Active today Expert Comment by:Guy Hengel [angelIII / a3]2008-07-14 can you show more details like the table design you query and the test code to reproduce the problem= 0 Message Author Comment by:kbios2008-07-14 dbWhereCondition = "SELECT * FROM order_line WHERE order_num = '" & ordnum & "' AND line_num =" & ctrvar Dim oldb As ADODB.Connection Set oldbRecordset = New ADODB.Recordset Set oldb = New Connection oldb.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=N:\databases\gwi.mdb;Jet OLEDB:Database Password=xxxxx;" oldbRecordset.Open dbWhereCondition, oldb, _ adOpenDynamic, adLockOptimistic, adCmdTableDirect 'reccountvar = 0 'Do Until oldbRecordset.EOF ' reccountvar = reccountvar + 1 'Loop 'If reccountvar = 0 Then ' MsgBox "FATAL ERROR: CANNOT FIND THE LINE ITEM IN THE ORDER LINE TABLE" ' Exit Sub 'End If IF I REFERENCE oldbRecordset AT THIS POINT I GET THE 3021 ERROR. 0 LVL 142 Overall: Level 142 Visual
ron Members Profile Send Private Message Find Members Posts Add to Buddy List Newbie Joined: 26-May-2016 Status: Offline Points: 3 Post Options Post Reply Quoteron Report Post Thanks(0) QuoteReply Topic: Either BOF or EOF is true...Error 3021Posted: 26-May-2016 at 10:40am So, when I add a new product - I can edit it - assign it to a category, what-have-you. However, when I try to preview the item from the edit page - I get the following error. When I try to view the category that contains the new item, it gives the same error. Oddly, I have looked in the database itself and see the item with all the information. Anyone seen this one before? I need to add several products but currently can't.Date/Time: 5/26/2016Session ID: 933999624Error Number: 3021Source: ADODB.FieldDescription: Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.query=SELECT idDiscountperquantity FROM discountsperquantity WHERE idproduct=3848 and discountPerUnit<>0Request Method: GETServer Port: 80HTTPS: offUser Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36URL: /pc/viewCategories.aspHTTP Headers: www.hottubsforless.com, en-US,en;q=0.8 Greg Dinger Members Profile Send Private Message Find Members Posts Add to Buddy List Certified ProductCart Developers Joined: 23-September-2006 Location: United States Status: Offline Points: 215 Post Options Post Reply QuoteGreg Dinger Report Post Thanks(0) QuoteReply Posted: 26-May-2016 at 11:18am I guess the first question is what version store code are you running, and do you have an active support plan. If you have a support plan, you probably want to submit a support request to the authors.I'm suspecting that you have the "on error resume next" commented out in /tanningbeds/includes/opendb.asp. That may have been done to debug something else, and was overlooked. By removing the single quote from the beginning of that line you may be able to ge