Home > 2185 access > 2185 access error

2185 Access Error

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 run time error 2185 access site About Us Learn more about Stack Overflow the company Business Learn more

Run Time Error 2185 Access Vba

about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x

You Cannot Reference A Property Or Method For A Control Unless The Control Has The Focus

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 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.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,20441435 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. –agnes Dec 20 '13 at 12:49 I get a 2465 runtime error, and is highlighted the Docmd section in yellow. –St

be down. Please try the request again. Your cache administrator is webmaster. Generated Fri, 30 Sep 2016 01:32:14 GMT by s_bd40 (squid/3.5.20)

+ Ask a Question Need help? Post your question and get tips & solutions from a community of 418,416 IT Pros & Developers. It's quick & easy. Run-time error '2185' You can't reference a https://bytes.com/topic/access/answers/844004-run-time-error-2185-you-cant-reference-property-method property or method P: 77 Sep410 Hi all, Here is my code: Expand|Select|Wrap|Line Numbers PrivateSubCommand12_Click() http://www.access-programmers.co.uk/forums/showthread.php?t=181061 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 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 2185 access Numbers 'Me!txtEmail.SetFocus There are some SQL statements which has 2 conditions I can't set the focus for both of 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 run time error 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 causing events to trigger. Sir Devo Nov 12 '09 #5 reply Expert 2.5K+ P: 3,532 missinglinq As I said previously, there is seldom any reason to use the Text Property in Access VBA, and it certainly shouldn't be used to set value of a textbox! If you need to change the value of a textbox thru code, use the Value Property, which doesn't require setting the focus to the textbox. Me.TextboxName.Value = "Whatever" Since the Value Property is the default property for textboxes, comboboxes, etc., you can simply use Me.TextboxName = "Whatever" omitting the .Value. Welcome to Bytes! Linq ;0)> Nov 12 '09 #6 reply Message Cancel Changes Post your repl

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 Rate Thread Display Modes 10-09-2009, 09:45 AM #1 cursedeye Newly Registered User Join Date: Oct 2009 Posts: 50 Thanks: 0 Thanked 1 Time in 1 Post 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: Quote: 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 End Sub Thanks cursedeye View Public Profile Find More Posts by cursedeye 10-09-2009, 09:48 AM #2 cursedeye Newly Registered User Join Date: Oct 2009 Posts: 50 Thanks: 0 Thanked 1 Time in 1 Post Re: VB Run Time Error '2185' How do I modify that? Thanks cursedeye View Public Profile Find More Posts by cursedeye 10-09-2009, 09:48 AM #3 pbaldy Wino Moderator Join Date: Aug 2003 Location: Nevada, USA Posts: 28,827 Thanks: 6 Thanked 3,211 Times in 3,157 Posts Re: VB Run Time Error '2185' Change this Me.Building.Text to Me.Building __________________ Paul Microsoft Access MVP To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. pbaldy View Public Profile Find More Posts by pbaldy 10-09-2009, 09:50 AM #4 pbaldy Wino Moderator Join Date: Aug 2003 Location: Nevada, USA Posts: 28,827 Thanks: 6 Thanked 3,211 Times in 3,157 Posts Re: VB Run Time Error '2185' Oh, and you're going to have a problem with no spaces between text on different lines. It looks like you allowed for it on the first line, but then forgot. __________________ Paul Microsoft Access MVP To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. pbaldy View Public Profile Find More Posts by pbaldy 10-09-2009, 09:58 AM #5 cursedeye Newly Registered User Join Date: Oct 2009 Po

 

Related content

No related pages.