Error Number 2185
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 Access 2010 Runtime Error 2185 up vote 1 down vote favorite Hi I have an application created in Access 2007, it's front-end and back-end is split. I am trying to open the database using Access 2010 runtime, however the application crashes when I change selected item of a combo box. I receive the following error: "Execution of this application has stopped due to a run-time error. The application can't continue and will be shut down." After researching the problem, a few people mentioned running the compact and repair, and found that fixed their problem, however it made no difference to mine. However, I found most people to come back and say put some error logging in place. So I have done that, and when running on 2010 runtime, a receive a pop up message saying the following: Error number: 2185, You can't reference a property or method for a control unless the control has the focus. However when running in Access 2007, there is no error and the code works fine. This is the code I have been using: Private Sub ComboBox1_Change() If Not ComboBox1.Text = "" Then ComboBox1.Dropdown End If End Sub My question is, why would this suddenly become an issue running on 2010 runtime, when there is no error in Access 2007? ms-access ms-access-2007 runtime-error ms-access-2010 share|improve this question asked Mar 22 '13 at 11:15 Mike 815 I had a few odd problems switching my test databases to 2010, but decompile sorted them out, or worst case scenario, importing to a new db. –Fionnuala Mar 22 '13 at 21:00 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote accepted change If Not ComboBox1.Text = "" Then to If Not ComboBox1 = "" Then For whatever reason Access does not like you use the .Text property outside of it's strict control. share|improve this answer answered Mar 22 '13 at 17:50 Brad 7,92621951 You can use text when a control has the focus, and as this is the change event for the control, it has the focus. –Fionnuala Mar 22 '13 at 20:58 I thought `change might be able to have
Top Posters Today's Posts Search Community Links Social Groups Pictures & Albums Members List Calendar Search Forums Show Threads Show Posts 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 read the Text in a combobox. The Value (usually an index) is available, but is not always what is http://stackoverflow.com/questions/15568970/access-2010-runtime-error-2185 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 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. http://www.access-programmers.co.uk/forums/showthread.php?t=199905 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, 311 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: "Peace is that brief glorious moment in history when everybody stands around reloading." Sitting is the new Smoking - Cut down on it and live longer Rx_ View Public Profile Find More Posts by Rx_ Tags 2185 , combobox , control , error , focus « Previous Thread | Next Thread &
+ Ask a Question Need help? Post your question and get tips & solutions from a https://bytes.com/topic/access/answers/844004-run-time-error-2185-you-cant-reference-property-method community of 418,536 IT Pros & Developers. It's quick & easy. Run-time error '2185' You can't reference a property or method P: 77 Sep410 Hi all, Here is my code: Expand|Select|Wrap|Line Numbers PrivateSubCommand12_Click() DimstrSqlAsString strSql="Deletefromtbl_citywhereCityId="&Val(Me!txtEmail.Text)&";" Setcn=CurrentProject.Connection cn.ExecutestrSql Debug.Print"MyTableViewcreated" Setcn=Nothing EndSub I get the Run-time error '2185' when I run it. You can't reference a property error number or method for a control unless the control has the focus .!!!!!!! If I put this line after defending of the strsql everything work well but I don't want to have this line in my code. Expand|Select|Wrap|Line Numbers 'Me!txtEmail.SetFocus There are some SQL statements which has 2 conditions I can't set the focus for both of error number 2185 them at the same time. Oct 7 '08 #1 Post Reply Share this Question 5 Replies Expert 2.5K+ P: 3,532 missinglinq In Access VBA the Text property is only available when the control has focus, as you've seen .The Text property is seldom used in VBA. Use the .Value Property instead. It doesn't require focus to work. And since it's the Default Property for a textbox/combobox, you don't actually have to include it! txtEmail is the same as txtEmail.Value Linq ;0)> Oct 7 '08 #2 reply P: 77 Sep410 Thank you.It is working now. Oct 7 '08 #3 reply Expert 2.5K+ P: 3,532 missinglinq Glad you got it working! Linq ;0)> Oct 7 '08 #4 reply P: 9 sirdevo I had a couple of textboxes I needed to change the .text property on, but when I would setfocus to update the textbox it would cause problems by activating all my events I had placed on those textboxes. It allows me to change the values without caus