Solved

MS Access Form - Runtime error 2135

Posted on 2011-02-15
14
2,359 Views
Last Modified: 2012-05-11
I have a VBA project and I want one of the text boxes on the form
to become zero when the user clicks a certain command button.

But, I am getting...
Run-timer error 2135
This property is read-only and cannot be set

But when I look at that text box's properties
Enabled = Yes, Locked = No

The code I have is in the OnClick event...
chkboxPaid.Value=True
Text54.SetFocus
Text54.Text="0"

Open in new window

0
Comment
Question by:--TripWire--
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
14 Comments
 
LVL 75
ID: 34899272
Try this

chkboxPaid.Value=True
Text54.SetFocus
Text54 ="0"
0
 
LVL 6

Expert Comment

by:Gugro
ID: 34899277
what is the ControlSource for the textfield ??
And you should use Text54 = "0"
as the property .Text  is only accessible when you are editing the TextBox
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 125 total points
ID: 34899316
Are you *sure* that text box does not have a calculated Control Source ... like

=<SomeExpression>

?

what you have should be working ...

mx
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 125 total points
ID: 34899325
"Text  is only accessible when you are editing the TextBox"
Not really the case.


From Help:
Text Property
You can use the Text property to set or return the text contained in a text box or in the text box portion of a combo box. Read/write String.


mx


0
 

Author Comment

by:--TripWire--
ID: 34899366
Thanks
I tried Text54=0 but problem still persists.

The control source of the txtbox is...
=IIf([Insurance] = "X", ([Total]-(0.15*[Total])-[Payment], ([Total]-[Payment]))

Open in new window

0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 125 total points
ID: 34899392
"The control source of the txtbox is..."
That is your problem.  You cannot set a value from Code when there is a calculated expression in the Control Source. .... sorry.

mx
0
 

Author Comment

by:--TripWire--
ID: 34899490
Ok thanks.  Good to know.
Can you suggest some other way to get that figure to zero?  I tried a nested IIf, but it does nothing.

=IIf([Paid]="Yes", 0, IIf(....etc...))
0
 
LVL 75
ID: 34899531
Under what condition is it supposed to be Zero ?

mx
0
 

Author Comment

by:--TripWire--
ID: 34899542
It's the user's choice.
The way I have it now is they click a command button, which sets a yes/no box to true.
And from now on, whenever the DB see's that Paid=true, the remaining balance goes to 0.
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 125 total points
ID: 34899567
Maybe this:

=IIf([chkboxPaid] = True, 0, IIf([Insurance] = "X", ([Total] - (0.15 * [Total])) - [Payment], ([Total] - [Payment])))
0
 

Author Comment

by:--TripWire--
ID: 34899581
That's what I have.  Does nothing so far.
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 125 total points
ID: 34899592
That's not exactly what you had ... you had [Paid] ... I'm using the control name.
0
 

Author Comment

by:--TripWire--
ID: 34899623
Nevermind, I had quotes around Yes.
Thanks - problem solved.
0
 
LVL 75
ID: 34899655
Cool.

thx.mx
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question