A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Set Focus



 
 
Thread Tools Display Modes
  #1  
Old July 8th, 2009, 12:44 PM posted to microsoft.public.access
dhstein
external usenet poster
 
Posts: 665
Default Set Focus

I thought I had this solved - but it looks like I don't. I set a combo box
to visible - and let the user select a value. I want to read that value and
then move the focus to another control and set the combo box to invisible
again. But I can't seem to get the focus off of the combo box. I've tried
this in the "After Update" event and the "Change" event - but I always get
the runtime error 2110 - can't set the focus etc. etc. Any help is
appreciated.

David

  #2  
Old July 8th, 2009, 01:10 PM posted to microsoft.public.access
BruceM[_4_]
external usenet poster
 
Posts: 558
Default Set Focus

You will not be able to use the Change event, which essentially runs after
every key stroke, but the After Update event should work:

Me.SomeControl.SetFocus

Assuming you are able to move the focus, try hiding the combo box in the Got
Focus event of the control to which you are moving the focus.

When posting a question about troublesome code it usually helps to post the
code.
"dhstein" wrote in message
...
I thought I had this solved - but it looks like I don't. I set a combo box
to visible - and let the user select a value. I want to read that value
and
then move the focus to another control and set the combo box to invisible
again. But I can't seem to get the focus off of the combo box. I've
tried
this in the "After Update" event and the "Change" event - but I always get
the runtime error 2110 - can't set the focus etc. etc. Any help is
appreciated.

David



  #3  
Old July 8th, 2009, 07:46 PM posted to microsoft.public.access
dhstein
external usenet poster
 
Posts: 665
Default Set Focus

Bruce,

Thanks for your reply - but I can't move the focus. The code is below:

Private Sub cbxFindVendor_AfterUpdate()

Me.txbVendorName = Me.cbxFindVendor.Value

VendorNameIs = Me.cbxFindVendor.Value

Me.cbxFindVendor.Value = ""


'Runtime Error 2110 on next line
Me.txbVendorName.SetFocus


Populate_Vendor (VendorNameIs)
End Sub

"BruceM" wrote:

You will not be able to use the Change event, which essentially runs after
every key stroke, but the After Update event should work:

Me.SomeControl.SetFocus

Assuming you are able to move the focus, try hiding the combo box in the Got
Focus event of the control to which you are moving the focus.

When posting a question about troublesome code it usually helps to post the
code.
"dhstein" wrote in message
...
I thought I had this solved - but it looks like I don't. I set a combo box
to visible - and let the user select a value. I want to read that value
and
then move the focus to another control and set the combo box to invisible
again. But I can't seem to get the focus off of the combo box. I've
tried
this in the "After Update" event and the "Change" event - but I always get
the runtime error 2110 - can't set the focus etc. etc. Any help is
appreciated.

David




  #4  
Old July 8th, 2009, 08:04 PM posted to microsoft.public.access
BruceM[_4_]
external usenet poster
 
Posts: 558
Default Set Focus

What is VendorNameIs? A user-defined function? A variable? I don't know
if that is affecting anything, but it would be worthwhile building hte code
one line at a time until you find where it doesn't work. First try:

Me.txbVendorName.SetFocus

What is the point of copying the value from one control to another, then
deleting it from the first control? On another point, you do not need to
specify Value, which is the default property. It does no harm, but it is
not necessary.

"dhstein" wrote in message
...
Bruce,

Thanks for your reply - but I can't move the focus. The code is below:

Private Sub cbxFindVendor_AfterUpdate()

Me.txbVendorName = Me.cbxFindVendor.Value

VendorNameIs = Me.cbxFindVendor.Value

Me.cbxFindVendor.Value = ""


'Runtime Error 2110 on next line
Me.txbVendorName.SetFocus


Populate_Vendor (VendorNameIs)
End Sub

"BruceM" wrote:

You will not be able to use the Change event, which essentially runs
after
every key stroke, but the After Update event should work:

Me.SomeControl.SetFocus

Assuming you are able to move the focus, try hiding the combo box in the
Got
Focus event of the control to which you are moving the focus.

When posting a question about troublesome code it usually helps to post
the
code.
"dhstein" wrote in message
...
I thought I had this solved - but it looks like I don't. I set a combo
box
to visible - and let the user select a value. I want to read that
value
and
then move the focus to another control and set the combo box to
invisible
again. But I can't seem to get the focus off of the combo box. I've
tried
this in the "After Update" event and the "Change" event - but I always
get
the runtime error 2110 - can't set the focus etc. etc. Any help is
appreciated.

David






  #5  
Old July 8th, 2009, 11:54 PM posted to microsoft.public.access
dhstein
external usenet poster
 
Posts: 665
Default Set Focus

Bruce,

Thanks for your reply. I'm saving the value from the combobox into the
variable VendorNameIs. I use that variable in the subroutine which I call
later - Populate_Vendor. The problem is just with the setfocus method- if I
comment that out everything is working fine.

"BruceM" wrote:

What is VendorNameIs? A user-defined function? A variable? I don't know
if that is affecting anything, but it would be worthwhile building hte code
one line at a time until you find where it doesn't work. First try:

Me.txbVendorName.SetFocus

What is the point of copying the value from one control to another, then
deleting it from the first control? On another point, you do not need to
specify Value, which is the default property. It does no harm, but it is
not necessary.

"dhstein" wrote in message
...
Bruce,

Thanks for your reply - but I can't move the focus. The code is below:

Private Sub cbxFindVendor_AfterUpdate()

Me.txbVendorName = Me.cbxFindVendor.Value

VendorNameIs = Me.cbxFindVendor.Value

Me.cbxFindVendor.Value = ""


'Runtime Error 2110 on next line
Me.txbVendorName.SetFocus


Populate_Vendor (VendorNameIs)
End Sub

"BruceM" wrote:

You will not be able to use the Change event, which essentially runs
after
every key stroke, but the After Update event should work:

Me.SomeControl.SetFocus

Assuming you are able to move the focus, try hiding the combo box in the
Got
Focus event of the control to which you are moving the focus.

When posting a question about troublesome code it usually helps to post
the
code.
"dhstein" wrote in message
...
I thought I had this solved - but it looks like I don't. I set a combo
box
to visible - and let the user select a value. I want to read that
value
and
then move the focus to another control and set the combo box to
invisible
again. But I can't seem to get the focus off of the combo box. I've
tried
this in the "After Update" event and the "Change" event - but I always
get
the runtime error 2110 - can't set the focus etc. etc. Any help is
appreciated.

David







  #6  
Old July 9th, 2009, 12:09 PM posted to microsoft.public.access
BruceM[_4_]
external usenet poster
 
Posts: 558
Default Set Focus

Can you set focus if it is the only code in the After Update event? I ask
because I have no problem moving the focus in the After Update event (Access
2003), so it seems something else is preventing it. A process of
elimination may help pin down the problem.

Is VendorNameIs defined somewhere? Does the code compile properly?

"dhstein" wrote in message
...
Bruce,

Thanks for your reply. I'm saving the value from the combobox into the
variable VendorNameIs. I use that variable in the subroutine which I call
later - Populate_Vendor. The problem is just with the setfocus method- if
I
comment that out everything is working fine.

"BruceM" wrote:

What is VendorNameIs? A user-defined function? A variable? I don't
know
if that is affecting anything, but it would be worthwhile building hte
code
one line at a time until you find where it doesn't work. First try:

Me.txbVendorName.SetFocus

What is the point of copying the value from one control to another, then
deleting it from the first control? On another point, you do not need to
specify Value, which is the default property. It does no harm, but it is
not necessary.

"dhstein" wrote in message
...
Bruce,

Thanks for your reply - but I can't move the focus. The code is
below:

Private Sub cbxFindVendor_AfterUpdate()

Me.txbVendorName = Me.cbxFindVendor.Value

VendorNameIs = Me.cbxFindVendor.Value

Me.cbxFindVendor.Value = ""


'Runtime Error 2110 on next line
Me.txbVendorName.SetFocus


Populate_Vendor (VendorNameIs)
End Sub

"BruceM" wrote:

You will not be able to use the Change event, which essentially runs
after
every key stroke, but the After Update event should work:

Me.SomeControl.SetFocus

Assuming you are able to move the focus, try hiding the combo box in
the
Got
Focus event of the control to which you are moving the focus.

When posting a question about troublesome code it usually helps to
post
the
code.
"dhstein" wrote in message
...
I thought I had this solved - but it looks like I don't. I set a
combo
box
to visible - and let the user select a value. I want to read that
value
and
then move the focus to another control and set the combo box to
invisible
again. But I can't seem to get the focus off of the combo box.
I've
tried
this in the "After Update" event and the "Change" event - but I
always
get
the runtime error 2110 - can't set the focus etc. etc. Any help is
appreciated.

David









  #7  
Old July 9th, 2009, 12:35 PM posted to microsoft.public.access
dhstein
external usenet poster
 
Posts: 665
Default Set Focus


Bruce - you're right something else is preventing this from working. But at
this point I found a work around and that will have to be my solution for
now. Basically, I set up a LostFocus event for the control to set its
visible property to FALSE. Then in the change event I set focus to a
different form and then back again to this form. That allows the lost focus
to trigger and it works. Thanks for your help.

David

"BruceM" wrote:

Can you set focus if it is the only code in the After Update event? I ask
because I have no problem moving the focus in the After Update event (Access
2003), so it seems something else is preventing it. A process of
elimination may help pin down the problem.

Is VendorNameIs defined somewhere? Does the code compile properly?

"dhstein" wrote in message
...
Bruce,

Thanks for your reply. I'm saving the value from the combobox into the
variable VendorNameIs. I use that variable in the subroutine which I call
later - Populate_Vendor. The problem is just with the setfocus method- if
I
comment that out everything is working fine.

"BruceM" wrote:

What is VendorNameIs? A user-defined function? A variable? I don't
know
if that is affecting anything, but it would be worthwhile building hte
code
one line at a time until you find where it doesn't work. First try:

Me.txbVendorName.SetFocus

What is the point of copying the value from one control to another, then
deleting it from the first control? On another point, you do not need to
specify Value, which is the default property. It does no harm, but it is
not necessary.

"dhstein" wrote in message
...
Bruce,

Thanks for your reply - but I can't move the focus. The code is
below:

Private Sub cbxFindVendor_AfterUpdate()

Me.txbVendorName = Me.cbxFindVendor.Value

VendorNameIs = Me.cbxFindVendor.Value

Me.cbxFindVendor.Value = ""


'Runtime Error 2110 on next line
Me.txbVendorName.SetFocus


Populate_Vendor (VendorNameIs)
End Sub

"BruceM" wrote:

You will not be able to use the Change event, which essentially runs
after
every key stroke, but the After Update event should work:

Me.SomeControl.SetFocus

Assuming you are able to move the focus, try hiding the combo box in
the
Got
Focus event of the control to which you are moving the focus.

When posting a question about troublesome code it usually helps to
post
the
code.
"dhstein" wrote in message
...
I thought I had this solved - but it looks like I don't. I set a
combo
box
to visible - and let the user select a value. I want to read that
value
and
then move the focus to another control and set the combo box to
invisible
again. But I can't seem to get the focus off of the combo box.
I've
tried
this in the "After Update" event and the "Change" event - but I
always
get
the runtime error 2110 - can't set the focus etc. etc. Any help is
appreciated.

David










 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:33 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.