Ms Access Run Time Error 2185
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
You Cannot Reference A Property Or Method For A Control Unless The Control Has The Focus
or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x runtime error 424 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 2185 up vote 2 down vote favorite I getting a run time error 2185, "You can't reference a property or method for a control unless the control has the focus ...". This is my code that I am using. Private Sub Command5_Click() Dim cardno As Integer cardno = cardnumber.Text DoCmd.OpenForm "search_card_number", acNormal, , WHERE & cardno = [Account Number] End Sub ms-access access-vba share|improve this question edited Dec 20 '13 at 16:30 HansUp 79.3k114371 asked Dec 20 '13 at 12:17 Steve 481211 add a comment| 3 Answers 3 active oldest votes up vote 3 down vote Referencing the .Text property of a control requires it to have focus. Simply drop that and it should work (the default is .Value) OR Try putting in the SetFocus method as advised by Access, i.e. Private Sub Command5_Click() Dim cardno As Integer cardnumber.SetFocus <-------Use this line to set the focus cardno = cardnumber.Text DoCmd.OpenForm "search_card_number", acNormal, , WHERE & cardno = [Account Number] End Sub share|improve this answer answered Dec 20 '13 at 12:35 sonams 1,20741435 I get a runtime error 6, overflow. but the carnumber.text did get the value I was enter in textbox –Steve Dec 20 '13 at 12:42 I guess data can no longer be held by an integer. Try changing the line Dim cardno As Integer to Dim cardno As Long should fix the immediate problem. –sonams Dec 20 '13 at 12:49 I get a 2465 runtime error, and is highlighted the Docmd section in yellow. –Steve Dec 20 '13 at 12:55 add a comment| up vote 1 down vote That run time error means You can't reference a property or method for a control unless the control has the focus. You can use .Text when a control has the focus. share|improve this answer answered Dec 20 '13 at 12:22 Siddharth Rout 91.5k11102146 if I change the text to textbox, I get a data and method member not found –Steve Dec 20 '13 at 12:40 1 use cardno = cardnumber instead of cardno = cardnumber.Text –Siddharth Rout Dec 20
be down. Please try the request again. Your cache administrator is webmaster. Generated Thu, 20 Oct 2016 21:29:42 GMT by s_wx1126 (squid/3.5.20)
Question Need help? Post your question and get tips & solutions from a community of 418,595 IT Pros & Developers. It's quick https://bytes.com/topic/access/answers/761914-runtime-error-2185-control-has-focus & easy. Runtime Error '2185' on control that has focus 100+ P: 675 OldBirdman I've spent all day on this, and can't see what I'm doing wrong. I've Googled and all http://www.andreavb.com/forum/viewtopic_7080.html I find have the same mistake, using .Text when they should use .Value. In this case, .Text is correct. Expand|Select|Wrap|Line Numbers PrivateSubtxtSearch_Change() DimwkAsString wk=Me.txtSearch.Text'ThisisthestatementthatgetsRuntimeError'2185' ... EndSub I tried wk = time error txtSearch.Text to no avail. I tried txtSearch.SetFocus before the use/assignment, also didn't work. Obviously, the control has the focus, as I am typing in it, and want to monitor what is entered, as it is entered. Trying to trick Access into doing my bidding, I tried Expand|Select|Wrap|Line Numbers PrivateSubtxtSearch_Change() DimwkAsString cmdExit.SetFocus wk=txtSearch txtSearch.SetFocus txtSearch.SelStart=255 ... EndSub Now wk has the correct information, ms access run but the error occurs on the .SelStart = 255 statement. Leaving that out means that the entire string in the TextBox is selected. Not acceptable. I copied the code for this control to a new database, new form with one control only. The code works. I copied the form to the new database, removed the RecordSource so I wouldn't have to duplicate the entire program. Works fine. I don't want the code debugged, as the code works. I'm looking for ideas about what, on a form, might conflict with the "Got Focus". You know, like if the TextBox Backcolor is light blue, the moon is full, and the form is modal, there is trouble, so change on of these. That kind of idea. OldBirdman Jan 22 '08 #1 Post Reply Share this Question 6 Replies Expert 2.5K+ P: 3,532 missinglinq Expand|Select|Wrap|Line Numbers PrivateSubtxtSearch_Change() DimwkAsString wk=Me.txtSearch.Text'ThisisthestatementthatgetsRuntimeError'2185' ... EndSub The .Text property is, indeed, appropriate in this context; it's one of the few times/events where it should be used. And it works fine for me, first time out, as it should have for you! Aside from corru
applications Pocket PC API Network ActiveX VBA (Access, Excel, Word, ...) Multimedia Other .NET Languages ASP.NET C# VB Anything Non-English ONLY Off-Topic Today's active posts Search Source Code API Calls List Beginner's corner Miscellaneous source code Miscellaneous API Files and disks code COM and LPT ports Form's API Windows NT/2000/XP Printing in Visual Basic Registry and INI Files Video, bitmaps and colors Winsock, NetAPI and internet VB and VBA for Word and Access Database management VB Script and ASP Articles and tutorials Downloads Visual Basic for beginners Miscellaneous source code API - Application Program Interface Files and disks Bluetooth, COM, LPT, USB ports Printing in Visual Basic Graphics Winsock, NetAPI and internet VBA - Visual Basic for Applications Database Full controls e-Books Visual Basic games Submit your code News Visual Basic books News for programmers AndreaVB downloads - news and comments Search/offer jobs Links Partners Marco Bortolani robertoventurelli.com Links Directory ...Other links Contacts Advertise with us Feedback Drop us a comment Link to us AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile AndreaVB Forum : Database : Run-time Error assigning text to/from textbox - error 2185 Poster Message ba1959nhLevel: ScholarRegistered: 10-05-2006Posts: 30 Run-time Error assigning text to/from textbox - error 2185 I am getting the following error when I try to assign the value of a textbox to an integer in my Spin Button's SpinUp event handler. This error also occurs if I try to assign the textbox.text property to a string variable...... Run-time error 2185: You can't reference a propert or method for a control unless the control has focus. Perhaps this is a stupid question, but I just do NOT understand why this is happening. H E L P! ! ! CODE: Sub SpinBtnDonationAmt_SpinUp() Dim iValue As Integer Dim iIncrementer As Integer iIncrementer = 5 'Get the value out of the text box and store it in a variable iValue = Val(txtDonationAmt.Text) 'Increment the variable iValue = iValue + iIncrementer 'Put the value back into the text box txtDonationAmt.Text = str$(iValue) End Sub The error occurs on the iValue assignment line (iValue = Val(txtDonationAmt.Text) NOTE: The value of txtDonationAmt is set to 0 in Design mode, but when I run the Form, it displays #Name? which I am figuring is part of the problem because the value is no longer a number. 1) Why would the textbox value c