Error Run Time 3021
Contents |
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 run time error 3021 no current record with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack
Run Time Error 3021 Either Bof Or Eof Is True
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 run time error 3021 vb up Run time error 3021 - EOF or BOF is true or the current record has been deleted up vote 0 down vote favorite 1 rst.Open "SELECT * FROM Equipas WHERE ([ID - Funcionário] LIKE '" & idfunc & "' AND run time error 3201 [ID - Tarefa] LIKE ' " & idtask & "' );", CurrentProject.Connection, adOpenDynamic, adLockOptimistic rst.Delete adAffectCurrent rst.Update rst.Close I receive the runtime error 3021 however the query is not empty. vba ms-access access-vba share|improve this question edited Dec 12 '13 at 1:07 HansUp 79.2k114371 asked Dec 11 '13 at 23:41 user2898085 191312 Try dropping the ; at the end of the SQL. If that still doesn't work, try printing out the generated SQL and running it directly in Access. –Tim Williams
Runtime Error 3021 In Vba
Dec 11 '13 at 23:59 The issue in the duplicate question was the LIKE wild card character. Although this question also uses LIKE, there is no indication that a wild card is involved. –HansUp Dec 12 '13 at 8:15 add a comment| 1 Answer 1 active oldest votes up vote 5 down vote "I receive the runtime error 3021 however the query is not empty." Double check that point. Dim strSelect As String strSelect = "SELECT * FROM Equipas " & _ "WHERE ([ID - Funcionário] LIKE '" & _ idfunc & "' AND [ID - Tarefa] LIKE ' " & idtask & "' );" Debug.Print strSelect rst.Open strSelect, CurrentProject.Connection, adOpenDynamic, adLockOptimistic If rs.BOF And rs.EOF Then MsgBox "recordset is empty" Else rs.MoveLast MsgBox "recordset contains " & rs.RecordCount & " rows" End If 'rst.Delete adAffectCurrent 'rst.Update rst.Close If that version of the code tells you "recordset is empty", go to the Immediate window (Ctrl+g) to examine the SELECT statement the code built. You can copy the statement text and paste it into SQL View of a new Access query for testing. My best guess is the query returns no rows because it includes a space just before the value of idtask, and no [ID - Tarefa] values match space plus idtask: idfunc & "' AND [ID - Tarefa] LIKE ' " & idtask & "' );" ^ here share|improve this answer edited Oct 13 '15 at 18:30 answered Dec 12 '13 at 1:06 HansUp
be down. Please try the request again. Your cache administrator is webmaster. Generated Fri, 14 Oct 2016 17:04:32 GMT by s_wx1094 (squid/3.5.20)
Question Need help? Post your question and get tips & solutions from a community of 418,544 IT Pros & Developers. It's quick & easy. https://bytes.com/topic/access/answers/920315-how-do-i-avoid-error-3021-no-current-record How do I Avoid Error 3021: No Current Record P: 2 psdsen Please http://www.tek-tips.com/viewthread.cfm?qid=1170787 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 Else rs_Data.MoveNext EndIf txtnm.Text=rs_Data!ename EndSub Oct 22 time error '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 all active records, so you cannot execute a move to time error 3021 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,408 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.Text=rs_Data!ename CaseElse MsgBoxErr.Description,vbExclamation,"ErrorincmdNext_Click()" EndSelect ResumeExit_cmdNext EndSub Oct 22 '11 #4 reply P: 2 psdsen @Stewart Its all for test purpose only. Pleas
Join INTELLIGENT WORK FORUMSFOR COMPUTER PROFESSIONALS Log In Come Join Us! Are you aComputer / IT professional?Join Tek-Tips Forums! Talk With Other Members Be Notified Of ResponsesTo Your Posts Keyword Search One-Click Access To YourFavorite Forums Automated SignaturesOn Your Posts Best Of All, It's Free! Join Us! *Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail. Posting Guidelines Promoting, selling, recruiting, coursework and thesis posting is forbidden.Tek-Tips Posting Policies Jobs Jobs from Indeed What: Where: jobs by Link To This Forum! Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.Just copy and paste the BBCode HTML Markdown MediaWiki reStructuredText code below into your site. Microsoft: Access Modules (VBA Coding) Forum at Tek-Tips HomeForumsProgrammersDBMS PackagesMicrosoft: Access Modules (VBA Coding) Forum Run Time Error 3021 thread705-1170787 Forum Search FAQs Links MVPs Run Time Error 3021 Run Time Error 3021 SPL26 (TechnicalUser) (OP) 30 Dec 05 11:19 Hi,Can anybody help me, I'm getting a error message with the following code. The error message is RUN-TIME ERROR '3021' NO CURRENT RECORD.What I'm trying to do is to update a value in one table from another table. The table I'm updating has a one-to-many relationship with the table which I'm updating from, and the error message occures at the very end after it has updated the records.RegardsPaul LPublic Function Update_Lvl3()Dim db As Database, level3 As Recordset, Activ As Recordset, ReturnValue As VariantSet db = CurrentDb()Set level3 = db.OpenRecordset("SELECT DISTINCTROW LEVEL_3_DETAILS.* FROM LEVEL_3_DETAILS ORDER BY ACP_NO;")Set Activ = db.OpenRecordset("SELECT DISTINCTROW RESOURCES.* FROM RESOURCES ORDER BY ACP_NO;")DoCmd.Hourglass TrueDo While Not level3.NoMatchCURRENT_ESTIMATE = 0#EARNED_HOURS = 0#Do While level3!ACP_NO = Activ!ACP_NOCURRENT_ESTIMATE = CURRENT_ESTIMATE + (Activ![WEIGHTING])EARNED_HOURS = EARNED_HOURS + (Activ![PROGRESS_WEIGHT])Activ.MoveNextLooplevel3.LockEdits = Falselevel3.Editlevel3!CURRENT_ESTIMATE = CURRENT_ESTIMATElevel3!EARNED_HOURS = EARNED_HOURSIf level3!CURRENT_ESTIMATE = 0 Or level3!EARNED_HOURS = 0 Thenlevel3!