Ms Access Vba 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
You Cannot Reference A Property Or Method For A Control Unless The Control Has The Focus
About Us Learn more about Stack Overflow the company Business Learn more about runtime error 424 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 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
be down. Please try the request again. Your cache administrator is webmaster. Generated Thu, 20 Oct 2016 19:34:49 GMT by s_wx1196 (squid/3.5.20)
Top Posters Today's Posts Search Community Links Social Groups Pictures & Albums Members List Calendar Search Forums Show Threads Show Posts http://www.access-programmers.co.uk/forums/showthread.php?t=199905 Tag Search Advanced Search Find All Thanked Posts Go to Page... Thread Tools Rating: Display Modes 10-06-2010, 08:00 AM #1 Rx_ Nothing In Moderation Join Date: Oct 2009 Location: Denver, Colorado Posts: 2,633 Thanks: 557 Thanked 308 Times in 282 Posts [solved] Error 2185 You can't reference a property or method for a control Trying to ms access read the Text in a combobox. The Value (usually an index) is available, but is not always what is needed. Sometimes we want the text. The Text property is not available unless the control has the focus. Here is an alternative Run-time error '2185': You can't reference a property or method for a control unless the control has the focus. Read several ms access vba quetions and feel that this is what people were asking for. Did not readily find a post that puts the answer up front. This might help the search. Immediate Window example: ' combobox- retrieving Values ? Me!id_area.value 24 ? Me!id_area.Text *** SEE ERROR GENERATED --->>> 2185 Alternate Method ? Me!ID_Area.Column(0) 24 ? Me!ID_Area.Column(1) ND - Main Store Note: Column(1) is a contrived value from two or more fields Example: msgbox "Thank You for choosing " & Me!ID_Area.Column(1), VBOKOnly, "Thanks Bonehead - for purchasing a T-Rex skull" Also See: http://www.access-programmers.co.uk/...d.php?t=199489 Attached Images Error 2185 solved.png (12.4 KB, 312 views) __________________ Were you lucky enough to get an answer? Please mark your question as [SOLVED] The original poster can go to Thread Tools to mark it as Solved. This will help others later who search to find solutions. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. Clicking the THANKS and clicking on the SCALES can be a bonus! The volunteers will often remember your appreciation and help again. Quotation Thomas Jefferson: "Pea