PC Review


Reply
Thread Tools Rate Thread

'can't move focus to control ...'

 
 
Jonathan Leonard
Guest
Posts: n/a
 
      13th May 2004
'can't reference a property or method unless the control has focus'

these two errors in combination with one another are making things very
difficult (or impossible). i have a textbox whose default value which i
assume is the value property doesn't update on the onChange event. however,
it's text property does. so, i want to read the text property value.
problem with that is the control must have focus. problem with that is the
'can't move focus to control' error. can anybody help?

much thanks to anyone who knows just the right combination of quirk
workarounds here.



 
Reply With Quote
 
 
 
 
tina
Guest
Posts: n/a
 
      14th May 2004
the DefaultValue property and the Value property are not the same thing.
suggest you read up on the topics in Help, and post again if you need
further assistance.

hth


"Jonathan Leonard" <(E-Mail Removed)> wrote in message
news:M5adnezvafZ8fD7dRVn-(E-Mail Removed)...
> 'can't reference a property or method unless the control has focus'
>
> these two errors in combination with one another are making things very
> difficult (or impossible). i have a textbox whose default value which i
> assume is the value property doesn't update on the onChange event.

however,
> it's text property does. so, i want to read the text property value.
> problem with that is the control must have focus. problem with that is

the
> 'can't move focus to control' error. can anybody help?
>
> much thanks to anyone who knows just the right combination of quirk
> workarounds here.
>
>
>



 
Reply With Quote
 
 
 
 
Ken Snell
Guest
Posts: n/a
 
      14th May 2004
In order for the OnChange event to occur, the control that is being changed
must have the focus. Programmatically changing the value of that control
does not cause the event to occur. Thus, I'm confused by what you're trying
to do here.

Please provide more specific details so that we can identify a solution for
you.

--
Ken Snell
<MS ACCESS MVP>

"Jonathan Leonard" <(E-Mail Removed)> wrote in message
news:M5adnezvafZ8fD7dRVn-(E-Mail Removed)...
> 'can't reference a property or method unless the control has focus'
>
> these two errors in combination with one another are making things very
> difficult (or impossible). i have a textbox whose default value which i
> assume is the value property doesn't update on the onChange event.

however,
> it's text property does. so, i want to read the text property value.
> problem with that is the control must have focus. problem with that is

the
> 'can't move focus to control' error. can anybody help?
>
> much thanks to anyone who knows just the right combination of quirk
> workarounds here.
>
>
>



 
Reply With Quote
 
Jonathan Leonard
Guest
Posts: n/a
 
      14th May 2004
"Ken Snell" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> In order for the OnChange event to occur, the control that is being

changed
> must have the focus. Programmatically changing the value of that control
> does not cause the event to occur. Thus, I'm confused by what you're

trying
> to do here.
>
> Please provide more specific details so that we can identify a solution

for
> you.
>


i apologize for the misunderstanding. it is not from the onChange
event that i'm trying to read the value of .text or the control would have
focus and that would work properly. but, it is the behaviour of the default
value in relation to the onChange event (that is, it doesn't update between
events even though the user is typing things and the .text property is
changing) which
forces me to use a non-default property (that is, the text property) in a
function that is called from both the textbox's onChange event and from the
form's afterUpdate event.




 
Reply With Quote
 
Jonathan Leonard
Guest
Posts: n/a
 
      14th May 2004
> the DefaultValue property and the Value property are not the same thing.
> suggest you read up on the topics in Help, and post again if you need
> further assistance.
>


sorry, tina. i'm not referring to the DefaultValue property, but rather the
default property for that control (which happens to be 'value' if i'm not
mistaken). the problem is that in vba, when you use any property that is
not the default property (either read or write), then that control must have
focus. however, i get the error 'can't move focus to control..' when i try
to setFocus to it.



 
Reply With Quote
 
Ken Snell
Guest
Posts: n/a
 
      14th May 2004
You are correct that the .Value property does not change while the displayed
value is being changed -- the .Text property changes during this time. The
..Value property changes before the BeforeUpdate event occurs.

But I still ask the question from before. How are you changing the value
displayed in the control unless it already has the focus? You need to give
us more information about what you're trying to do here so that we might
help identify a solution.


--
Ken Snell
<MS ACCESS MVP>

"Jonathan Leonard" <(E-Mail Removed)> wrote in message
news:wMOdnWAvUsMnSzndRVn-(E-Mail Removed)...
> "Ken Snell" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > In order for the OnChange event to occur, the control that is being

> changed
> > must have the focus. Programmatically changing the value of that control
> > does not cause the event to occur. Thus, I'm confused by what you're

> trying
> > to do here.
> >
> > Please provide more specific details so that we can identify a solution

> for
> > you.
> >

>
> i apologize for the misunderstanding. it is not from the onChange
> event that i'm trying to read the value of .text or the control would have
> focus and that would work properly. but, it is the behaviour of the

default
> value in relation to the onChange event (that is, it doesn't update

between
> events even though the user is typing things and the .text property is
> changing) which
> forces me to use a non-default property (that is, the text property) in a
> function that is called from both the textbox's onChange event and from

the
> form's afterUpdate event.
>
>
>
>



 
Reply With Quote
 
tina
Guest
Posts: n/a
 
      14th May 2004
ah, value as default property, yes that's correct, my misunderstanding.

the problem is that in vba, when you use any property that is
> not the default property (either read or write), then that control must

have
> focus.


i'd say that's not correct, but i may again be misunderstanding your
meaning. in any case, you've established a dialogue with Ken Snell. as an
MVP, he is a better resource for you than i am, so i will butt out of this
thread so you can work with him uninterrupted.


"Jonathan Leonard" <(E-Mail Removed)> wrote in message
news:AuWdneYYOKtiSjndRVn-(E-Mail Removed)...
> > the DefaultValue property and the Value property are not the same thing.
> > suggest you read up on the topics in Help, and post again if you need
> > further assistance.
> >

>
> sorry, tina. i'm not referring to the DefaultValue property, but rather

the
> default property for that control (which happens to be 'value' if i'm not
> mistaken). the problem is that in vba, when you use any property that is
> not the default property (either read or write), then that control must

have
> focus. however, i get the error 'can't move focus to control..' when i

try
> to setFocus to it.
>
>
>



 
Reply With Quote
 
Jonathan Leonard
Guest
Posts: n/a
 
      17th May 2004
> You are correct that the .Value property does not change while the
displayed
> value is being changed -- the .Text property changes during this time. The
> .Value property changes before the BeforeUpdate event occurs.
>


> But I still ask the question from before. How are you changing the value
> displayed in the control unless it already has the focus? You need to give
> us more information about what you're trying to do here so that we might
> help identify a solution.


The control's value is being changed by the user typing information.
However, I have a function that is called from both the OnChange event
handler of each control and also from the Form_AfterUpdate which needs to
read the .Text values of each control and update the database. Hope that
makes it clear.

Please keep in mind that these controls are not bound to anything. That's
why I'm having to write this code. A portion of my controls is bound and a
portion is not bound. I don't know if BeforeUpdate is even called for an
unbound control. I'll do some testing to see about that. If it turns out
to be called, I could just move my OnChange event handling code to the
BeforeUpdate event handler for the unbound controls. Thanks much for your
help thus far!

Jonathan



 
Reply With Quote
 
Ken Snell
Guest
Posts: n/a
 
      18th May 2004
BeforeUpdate and AfterUpdate events both occur for bound and unbound
controls. When they occur depends upon the type of control -- for example, a
combo box or list box "click" will trigger both events, while just typing in
a textbox will not trigger them until you try to leave the textbox.

--
Ken Snell
<MS ACCESS MVP>

"Jonathan Leonard" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> > You are correct that the .Value property does not change while the

> displayed
> > value is being changed -- the .Text property changes during this time.

The
> > .Value property changes before the BeforeUpdate event occurs.
> >

>
> > But I still ask the question from before. How are you changing the value
> > displayed in the control unless it already has the focus? You need to

give
> > us more information about what you're trying to do here so that we might
> > help identify a solution.

>
> The control's value is being changed by the user typing information.
> However, I have a function that is called from both the OnChange event
> handler of each control and also from the Form_AfterUpdate which needs to
> read the .Text values of each control and update the database. Hope that
> makes it clear.
>
> Please keep in mind that these controls are not bound to anything. That's
> why I'm having to write this code. A portion of my controls is bound and

a
> portion is not bound. I don't know if BeforeUpdate is even called for an
> unbound control. I'll do some testing to see about that. If it turns out
> to be called, I could just move my OnChange event handling code to the
> BeforeUpdate event handler for the unbound controls. Thanks much for your
> help thus far!
>
> Jonathan
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Form focus will not move from control to control Mike in Colorado Microsoft Access Form Coding 0 3rd Dec 2007 07:28 AM
emulating window.focus in Body onload() event and setting focus to a control on same page Jason Microsoft ASP .NET 4 7th May 2007 06:54 PM
giving control focus = Focus? Select? ActiveControl? Activate? Zytan Microsoft VB .NET 9 19th Feb 2007 02:42 AM
Control's, Focus, and Change focus Jon Slaughter Microsoft C# .NET 4 19th Nov 2006 01:31 PM
Error Message: Can't move focus to the control Danielle Windows XP Internet Explorer 0 18th Nov 2003 05:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:09 PM.