473,400 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

runtime error 2185

shyuada91
hye you all..i want to ask how to correct error in this code..when i insert data and want to clear it..runtime error 2185 come out...Please help me..

Error number: 2185, You can't reference a property or method for a control unless the control has the focus.

Expand|Select|Wrap|Line Numbers
  1. Private Sub KOSONGKAN_Click()
  2.  
  3.     txtID.Text = ""
  4.     txtKodSekolah.Text = ""
  5.     txtTingkatanTahun.Text = ""
  6.     txtNamaKelas.Text = ""
  7.     txtNamaMurid.Text = ""
  8.     txtNoKp.Text = ""
  9.     txtNoSijilLahir.Text = ""
  10.     txtTarikhLahir.Text = ""
  11.  
  12. End Sub
Dec 8 '15 #1
3 1809
zmbd
5,501 Expert Mod 4TB
The error is very self explanatory (unusual for MS errors :) )

You cannot generally change the "text" property of any control unless you first set the focus to the control.

Think of the text property as a "scratch paper" or marquee for the control and the value property as the actual notebook where things are kept. If bound then a copy of the notebook page is placed on the scratch paper (or in the case of a combobox/Listbox the marquee as sometimes the value is not the same as the displayed text). In anycase, the only time the text property is available is while the control has focus.

Expand|Select|Wrap|Line Numbers
  1. (...)
  2. '
  3. txtid.setfocus
  4. txtID.Text = ""
  5. '
  6. txtKodSekolah.setfocus
  7. txtKodSekolah.Text = ""
On the other hand, you can usually set the value property of the control without first setting the focus to the control

Expand|Select|Wrap|Line Numbers
  1. Private Sub KOSONGKAN_Click()
  2.    txtID.Value = ""
  3.    txtKodSekolah.Value = ""
  4.    txtTingkatanTahun.Value = ""
  5.    txtNamaKelas.Value = ""
  6.    txtNamaMurid.Value = ""
  7.    txtNoKp.Value = ""
  8.    txtNoSijilLahir.Value = ""
  9.    txtTarikhLahir.Value = ""
  10. End Sub 
any particular reason you were using the text property of the control?
Dec 8 '15 #2
do you mean i must used .Value for my code..I try used that but also error..runtime error 2448..you cannot assign value to this object..What I must do now
Dec 8 '15 #3
zmbd
5,501 Expert Mod 4TB
+ Unfortunately, you didn't mention which line of the code is failing...
++ Insert the STOP command as the very first line following your SUB declaration (such as line 2 in your original post) of your code and save.
++ click on your [KOSONGKAN] control.
++ you should enter the debugger at this point with the STOP as the highlighted command
++ [F8] to execute the next line of code. Which one is causing the error.

+ Are these controls bound to a record set?
That is to say, when in design view, with the properties pane open, what is the [control source] for each of the controls?
If any of the controls (such as [txtID] is bound to an autonumber field you will not be able to set that value.

Check your bytes.com inbox, I will forward you a copy of tutorials and resources.
Dec 8 '15 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Bob Bamberg | last post by:
Hello All, I have been trying without luck to get some information on debugging the Runtime Error R6025 - Pure Virtual Function Call. I am working in C++ and have only one class that is derived...
0
by: Paul | last post by:
Hi all, I have developed a system in Access 2000 (SP-3) for a client. The system run's fine on NT 4 and Windows XP and most Win2k machines. I say 'most' Win2k machines because there are a few...
7
by: wmkew | last post by:
Hello everyone I'm encountering a R6002 Runtime error and several bugs when trying to generate a simple Managed C++ application with .NET 2003. The main problem seems to arise from linking with...
8
by: g_man | last post by:
I am trying trap Runtime error 3022 (duplicates) in the click event of a command button that closes the form. I have code in the Form_Error event that does a good job of providing a more meaningful...
7
by: John | last post by:
Hi Everyone, I'm having this extremely annoying problem with Internet Explorer 6, giving me an error message saying "unknown runtime error" whenever I try to alter the contents of a <divelement...
6
by: OldBirdman | last post by:
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. ...
3
by: Jim Armstrong | last post by:
Hello all - This is driving me crazy. I have a table called tblClients - very simple, has the following fields: taxID (PK) ClientName SalesName The main form of my application allows a...
5
by: Sep410 | last post by:
Hi all, Here is my code: Private Sub Command12_Click() Dim strSql As String strSql = "Delete from tbl_city where CityId=" & Val(Me!txtEmail.Text) & ";" Set cn =...
2
by: Taccat | last post by:
I have a sub form which contains amongst other things 4 textboxes and a disabled button. My goal is that when all 4 text boxes are filled, the button enables, and if one text box is empty, it...
1
by: abhijaiswal | last post by:
Hi All, I am working on a project where I used to views (view1 and view2). I set my first page as view2. I have around 10 Textboxes, 5 dropdown, 4 List view and 6 buttons. When I run my web...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.