Access 2003 Runtime 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
Runtime Error 2185 Access Vba
About Us Learn more about Stack Overflow the company Business Learn more about run time error 2185 access hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss you cannot reference a property or method for a control unless the control has the focus 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 '
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,625 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 needed. Sometimes we want the text. The Text property is not available http://stackoverflow.com/questions/15568970/access-2010-runtime-error-2185 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. Immediate Window example: ' combobox- retrieving Values ? Me!id_area.value 24 ? Me!id_area.Text *** SEE ERROR GENERATED --->>> 2185 http://www.access-programmers.co.uk/forums/showthread.php?t=199905 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, 306 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 » Thread Tools Show Printable Version Email this Page Display Modes Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Rate This Thread Excellent Good Average Bad Terrible Forum Jump User Control Panel Private Messages Subscriptions Who'
Question Need help? Post your question and get tips & solutions from a community of 418,417 IT Pros & Developers. https://bytes.com/topic/access/answers/761914-runtime-error-2185-control-has-focus It's quick & easy. Runtime Error '2185' on control that has focus http://www.pcreview.co.uk/threads/selstart-error-run-time-2185.3308525/ 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 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 error 2185 tried wk = 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 time error 2185 wk has the correct information, 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
masks for dates on forms. I usually add code to force the cursor to the beginning of the text box using SelStart. Private Sub txtDate1_GotFocus() Me.txtDate1.SelStart = 0 End Sub I created a form and the above field functioned fine. After I added more controls and code I began to get a Run-time 2185 error -You can't reference a property or method for a control unless the control has the focus. Anyone know what causes this or is my form corrupted in some way? Thanks in advance for any help or insight, -- Scott S Guest, Nov 8, 2007 #1 Advertisements Allen Browne Guest Scott, the only case that comes to mind is where: - You have a form that contains no records, and - No new records can be added. In this case, the detail section goes completely blank. Any controls in the Form Header or Form Footer sections still show, but Access gets confused and can show this error message. More info in the first section of this article: http://allenbrowne.com/bug-06.html -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "ScottS" <> wrote in message news:... >I have been using input masks for dates on forms. I usually add code to > force the cursor to the beginning of the text box using SelStart. > > Private Sub txtDate1_GotFocus() > Me.txtDate1.SelStart = 0 > End Sub > > I created a form and the above field functioned fine. After I added more > controls and code I began to get a Run-time 2185 error -You can't > reference a > property or method for a control unless the control has the focus. > > Anyone know what causes this or is my form corrupted in some way? > > Thanks in advance for any help or insight, > -- > Scott S Allen Browne, Nov 9, 2007 #2 Advertisements Linq Adams via AccessMonster.com Guest "You can't reference a property or method for a control unless the control has the focus." So Access is saying that you're trying to do something to ControlA that you can only do when ControlA has focus, and ControlA doesn't have focus! One possibilty that comes to mind, especially when you speak of adding multiple controls and using the identical code on all of them, is that you've copied and pasted code and forgotten to change the control name in the code. Say you start with Private Sub txtDate1_Got