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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|