Ms Access 2007 Error 3021
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 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Run time error 3021- no current record up vote 1 down vote favorite 1 I want to link the result of a query to a Textbox but I get this error: here is my code: Dim rst As DAO.Recordset Set rst = CurrentDb.OpenRecordset("SELECT XValue, YValue,Wert FROM tb_DCM_Daten WHERE (FzgID=" & Forms!frm_fahrzeug!ID & " AND Name='" & List2.Value & "')") Text10.Text = rst!XValue //error in this line It should be return c.a 20 record Why do I get this error and how can I solve it? thnak you vba ms-access ms-access-2010 share|improve this question asked Jun 27 '13 at 6:46 Kaja 72342135 3 Rearrange your code so your SQL Statement is in a string variable, and print it out to the immediate window. That way you'll see if there's anything wrong with it. If nothing obvious, that the output SQL and put it in a query and verify that there is a record that matches your criteria. –GregHNZ Jun 27 '13 at 6:58 Thank you, that helps –Kaja Jun 27 '13 at 7:17 add a comment| 3 Answers 3 active oldest votes up vote 5 down vote accepted One possible reason for the error is that Name is a reserved word in Access, so you should use ... & " AND [Name]='" & ... You could also test for rst.EOF before trying to use rst!XValue. That is, to verify whether or not your query is returning at least one row you can add the code If rst.EOF Then MsgBox "The Recordset is empty." End If immediately after the .OpenRecordset call. If the Recordset is empty, then you'll need to verify your SQL statement as described by @GregHNZ in his comment above. share|improve this answer edited Jun 27 '13 at 7:34 answered Jun 27 '13 at 6:51 Gord Thompson 56.4k74795 Thank you for your answer. I did it, but it doesn't help :/ –Kaja Jun 27 '13 at 6:55 1 @Kaja I have updated my answer. –Gord Thompson Jun 27 '13 at 7:35 add a comment| up vote 1 down vote Usually, I would do this. Create a new query in Access , switch to SQL View , Paste my code there and go to Design >> Run. SELECT XValue, YValue,Wert FROM [tb_DCM_Daten] WHERE [FzgID]=12 AND [Name]='ABC'; if your query syntax is correct you should see the result otherwise error mssg will tell where you are wrong.
Question Need help? Post your question and get tips & solutions from a community of 418,595 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 Else http://stackoverflow.com/questions/17336316/run-time-error-3021-no-current-record 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 all https://bytes.com/topic/access/answers/920315-how-do-i-avoid-error-3021-no-current-record 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,923 NeoPa Please read When Posting (VBA or SQL) Code before posting again. Oct 22 '11 #3 reply Expert 5K+ P: 8,410 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()
Technology and Trends Enterprise Architecture and EAI ERP Hardware IT Management and Strategy Java Knowledge Management Linux Networking Oracle PeopleSoft Project and Portfolio Management http://visualbasic.ittoolbox.com/groups/technical-functional/vb-access-l/run-time-error-3021-no-current-record-vba-4333968 SAP SCM Security Siebel Storage UNIX Visual Basic Web Design and http://www.dbforums.com/showthread.php?1633158-Run-time-error-3021-No-current-record Development Windows < Back CHOOSE A DISCUSSION GROUP Research Directory TOPICS Database Hardware Networking SAP Security Web Design MEMBERS Paul_Pedant DACREE MarkDeVries MacProTX VoIP_News Inside-ERP I_am_the_dragon Inside-CRM maxwellarnold Michael Meyers-Jouan TerryCurran Chris_Day Andrew.S.Baker Ramnath.Awate JoeTorre Locutus Craig Borysowich Dennis Stevenson mircea_luca Richard DukeGanote iudithm Clinton Jones bracke Nikki ms access Klein AbhaiTripathi Iqbalyk jakarman Adrian_Grigoriu knowscognosdoi COMPANIES SendGrid ZOHO Corporation Apperian eFax Corporate View All Topics View All Members View All Companies Toolbox for IT Topics Visual Basic Groups Ask a New Question Visual Basic for Access For discussion on Visual Basic for Access , please visit the Visual Basic – General Discussions group. More Visual Basic Groups Your account ms access 2007 is ready. You're now being signed in. Solve problems - It's Free Create your account in seconds E-mail address is taken If this is your account,sign in here Email address Username Between 5 and 30 characters. No spaces please The Profile Name is already in use Password Notify me of new activity in this group: Real Time Daily Never Keep me informed of the latest: White Papers Newsletter Jobs By clicking "Join Now", you agree to Toolbox for Technology terms of use, and have read and understand our privacy policy. Run Time Error 3021 , No current Record VBA Irfan Rana asked Jul 27, 2011 | Replies (6) I have two tables, One is a Data "LST_ SS" and other is the result "MML". I want to concatenate a field FAC of LST_ SS for each DN and update in Table "MML" , into field FAC. Here i am trying to get rid of it. Please assist how do control rsMML , there is error on rsMML update. Private Sub cmdMML_Click() DoCmd.OpenQuery "qryDISTINCT", acViewNormal Dim rsList A
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. Results 1 to 10 of 10 Thread: Run-time error 3021. No current record Tweet Thread Tools Show Printable Version Subscribe to this Thread… Search Thread Advanced Search Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 08-19-08,01:02 #1 Ashfaque View Profile View Forum Posts Registered User Join Date Jan 2005 Location Nanded, India Posts 397 Unanswered: Run-time error 3021. No current record Hello, Below are 2 VBA statements I placed after upted event of PurQty field in my footer form that will generate sum of the PurQty of respective part number in the same T_PurInvFoot table and at the same time it will sum the SalesQty from other table called T_SalesInvFoot for further calculation purposes. The first one which rst1 statement works fine as I am entering PurQty in it for desired any partnumber. It sums the PurQty from table. But when it comes to execute second statement which is rst2, the error apprears "Run-time error 3021" No current record I know that there is really no record for the entered matching partnumber in other table. But I want VBA to return me 0 (zero) if there is no simillar record available in T_SalesInvFoot. Set rst1 = CurrentDb.OpenRecordset("Select partnum, SUM(PurQty)AS NEWQTY from T_PurInvFoot Where PartNum='" & (PartNum) & "' GROUP BY partnum") Set rst2 = CurrentDb.OpenRecordset("Select partnum, SUM(SalesQty)AS SOLDQTY from T_SalesInvFoot Where PartNum='" & (PartNum) & "' GROUP BY partnum") How can I get 0 value if there is no record in other table? The above 2nd statement works fine when there is simillar partnum record in T_SalesInvFoot table. But it is not necessary that what I am purchasing currently should have sold earlier. This means there may or may not be simillar record in T_SalesInvFoot table. So my question is how can I get 0 value if there is no simillar record available using Select statement? Any idea? W