Text Property - read only?

E

ericgj

I am trying to set the text property of a textbox in order to trigger a
Change() event on it (Access 2003). The textbox is enabled, not locked,
visible, and unbound. I set focus to it before trying to change the text
property. Why is this giving me an error 2135, "This property is read-only
and can't be set"? The docs say Text is a read/write property.

Me.txtCount.SetFocus
Me.txtCount.Text = Cstr(ntot) ' ntot is Long

The current Value of Me.txtCount is "". I can change Me.txtCount.Value, but
of course this doesn't trigger the Change() event.

Any help greatly appreciated.
 
E

ericgj

Nevermind - answered my own question. You can't set the Text property on a
control (and probably many other properties) when you're still at the Load
event.
Hopefully this may be useful to others. I did what I needed to do a
different way.
 
J

John W. Vinson

Nevermind - answered my own question. You can't set the Text property on a
control (and probably many other properties) when you're still at the Load
event.
Hopefully this may be useful to others. I did what I needed to do a
different way.

The Text property *is* read/write - but only when the control has the focus.
This differs from Visual Basic's convention! What you can do is to set the
control's Value property; that is the default property so you can omit the
..value keyword if you wish and just use

Me!controlname = <whatever>
 
D

David W. Fenton

You can't set the Text property on a
control (and probably many other properties) when you're still at
the Load event.

Actually, it may be that the reason for this is that the control
can't really get the focus yet during the OnLoad event. You should
be able to just set the control's value in the OnLoad (or set the
value of the field in the underlying recordsource, which is already
available during the OnLoad event).

Also, I'm pretty sure you can't trigger the OnChange event of
controls in code -- only typing triggers that event (or, I guess,
pasting a value into the control).
 
J

John W. Vinson

John or David, could one of you explain to me why responses on this site get
posted in such a haphazard way? When my first response was posted, at 11-17-
2008 13:10, the OP's post of 11-17-2008 12:59 wasn't visible to me, which is
why I asked him ***where*** his code was placed. It's very confusing trying
to follow the flow of a thread, with questions being asked that ***appear***
to have already been answered.

Well, I see in your .sig



Accessmonster is one of many "repackagers" who take the USENET newsgroups
microsoft.public.access.* and display them through a user interface. Ask the
middleman why the posts are coming out of order.

It is worth noting that Usenet has always been chaotic in terms of time of
posting - and times of propagation from one server to another.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top