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 vb error 2185 and policies of this site About Us Learn more about Stack Overflow error 2185 access the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation runtime error 2185 access vba 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
Run Time Error 2185
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, you cannot reference a property or method for a control unless the control has the focus , WHERE & cardno = [Account Number] End Sub ms-access access-vba share|improve this question edited Dec 20 '13 at 16:30 HansUp 79.1k114371 asked Dec 20 '13 at 12:17 Steve 431211 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 agnes 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. &n
be down. Please try the request again. Your cache administrator is webmaster. Generated Sun, 09 Oct 2016 12:33:06 GMT by s_ac4 (squid/3.5.20)
is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can http://www.dbforums.com/showthread.php?505772-Microsoft-Access-VB-Run-Time-Error-2185 post: click the register link above to proceed. To start viewing messages, http://www.pcreview.co.uk/threads/selstart-error-run-time-2185.3308525/ select the forum that you want to visit from the selection below. Results 1 to 2 of 2 Thread: Microsoft Access VB Run Time Error '2185' Tweet Thread Tools Show Printable Version Subscribe to this Thread… Search Thread Advanced Search Display Linear Mode Switch to Hybrid error 2185 Mode Switch to Threaded Mode 09-16-02,23:19 #1 John316 View Profile View Forum Posts Registered User Join Date Sep 2002 Posts 68 Unanswered: Microsoft Access VB Run Time Error '2185' Question: I have a form with with a text box and when the user enters his information into text box after it saves I want it to automatically add the text error 2185 access ADA-xxxx. I have tried using MS accesses Build Event and choose "Expression Builder" But I am getting an error. Can Someone please help me??? The Error I am getting is: Microsoft Access Run-time error '2185': "You can't reference a property or method for a control unless the control has the focus. Try one of the following: 1) Move the focus to the control before you reference the property. In Visual Basic code, use the SetFocus method. In a macro, use the GoToControl action. 2) Reference or set the property from a macro or event procedure that runs when the GotFocus event for the Control occurs." My Code is listed below: Private Sub Form_BeforeUpdate(Cancel As Integer) If Left(LABEL_TAG.Text, 4) <> "ADA-" Then LABEL_TAG.Text = "ADA-" & LABEL_TAG.Text End If End Sub Reply With Quote 09-17-02,07:29 #2 nstaward View Profile View Forum Posts Registered User Join Date Aug 2002 Location Cambridge, England Posts 47 Try putting in the SetFocus method as advised by Access, i.e. Private Sub Form_BeforeUpdate(Cancel As Integer) Me.LABEL_TAG.SetFocus If Left(LABEL_TAG.Text, 4) <> "ADA-" Then LABEL_TAG.Text = "AD
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 al