Accesss Vba Forms Runtime Error 2185
Top Posters Today's Posts Search Community Links Social Groups Pictures & Albums Members List Calendar Search Forums run time error 2185 Show Threads Show Posts Tag Search Advanced Search Find All you cannot reference a property or method for a control unless the control has the focus 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 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 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 1
be down. Please try the request again. Your cache administrator is webmaster. Generated Fri, 30 Sep 2016 06:23:25 GMT by s_bd40 (squid/3.5.20)
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 http://www.pcreview.co.uk/threads/selstart-error-run-time-2185.3308525/ code I began to get a Run-time 2185 error -You can't reference a property or method for https://www.tutcity.com/access/error-2185-you-cant-reference-a-property-or-method-for-a-control-unless-the-control-has-focus.84574.html 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. error 2185 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 time error 2185 > 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_GotFocus() Me.txtDate1.SelStart = 0 End Sub then you add a new field, txtDate2. You copy and paste the above sub, and change txtDate1 to txtDate2 in the sub title, but forget to do so in the body of the sub, so that you end up with this Private Sub txtDate2_GotFocus() Me.txtDate1.SelStart = 0 End Sub Now,
in values of one textbox when another has been filled in, however, I am getting an error. Sponsored Links: Read full post... Report an issue Thank you for taking the time to report an issue. What's wrong... Please write below. And write your email address (optional) Similar posts... Run-time error '2185' for Dynamically search multiple fields I am trying to adpot this Dynamically search multiple fields into my db from John Big Booty at w w w.a c c e s s-p r o g r a m m e r s.co.uk/forums/showthread.php?t=188663 Every thing works great except it gives me run-time error when there's no resault from the search. The error shows: Run-Tim error '2185': you can't reference a property or method for a control unless the control has the focus. VB Run Time Error '2185' I keep getting an error: run-time error '2185' "you can't reference a property or method for a control unless the control has the focus." There is no problem with CheckFilter function, I checked. My Code: Private Sub Building_AfterUpdate() Call CheckFilter Dim sBuildingRoom As String sBuildingRoom = "SELECT DISTINCT Location.[Location ID],Location.Room " & _ "FROM Building INNER JOIN Location ON Building.[Building ID]=Location.[Building ID]" & _ "WHERE Building.[Building Name]= '" & Me.Building.Text & "'" & _ "ORDER by Location.Room" Me.Location.RowSource = sBuildingRoom Me.Location.Requery referencing a control Can anyone tell me what is wrong with this? Run time error '2185' You can't reference a property or method for a control unless the control has the focus. Private Sub AssignButton_Click() Dim SQLMasterUpdate As String Dim oItem As Variant If Me!RestaurantListBox.ItemsSelected.Count <> 0 Then For Each oItem In Me!RestaurantListBox.ItemsSelected SQLMasterUpdate = "UPDATE Restaurant SET " & _ "Restaurant.AccountManagerID = (SELECT AccountManagerID FROM AccountManager " & _ "WHERE AccountManagerName = " & Me!AccountManagerName.Text & ") " & _ "WHERE ((SELECT RestaurantInfo, RestaurantPhone FROM Restaurant) = " & oItem & ");" DoCmd.RunSQL SQLMasterUpdate Next oItem Else MsgBox "Nothing was selected from the list", vbInformation Exit Sub 'Nothing was selected Update Subform Recordsource If I hav