problem setting focus to Mainform Control

the rs is used all through out, but go ahead

The rs is used but you used WITH rs which then you only use that part with the .Close but you had many more places where you said rs.MoveNext or rs!FieldName where you should use !FieldName if you are using
With rs
 
First of all, you need to be aware where the context is when dealing with the code.

I am modifying your code you posted above. I'm removing some extraneous stuff and modifying based on the With rs that you never seem to use. Also I tried to highlight most of my changes in red.

thanks Bob,

cleans things up, but still not getting the focus working. I was not expecting this to be a problem. I guess I'll just use the Tab Stop Property set to NO on the other controls as that seemed to work.
 
The issue may be that you can't set the focus back from the after update event of the same control. Sometimes the focus thing can be a pain in the %**.
 
The issue may be that you can't set the focus back from the after update event of the same control. Sometimes the focus thing can be a pain in the %**.

I know, that's why I thought having it in the sub would do it? At the very least in the same place where I was clearing the control? Makes no sense to me.
 
I know, that's why I thought having it in the sub would do it? At the very least in the same place where I was clearing the control? Makes no sense to me.

Think about it this way. When you branch to another procedure, you still are within the scope of the procedure which called it. When the called procedure finishes you still come back through the one which called it. Therein lies the problem, I believe. In order to make it work, you would have to set the focus somwhere else and have it send it back. What could work is to have a small, .01 x .01 sized text box on the form and in the after update event you set the focus to it and in the mini text box's GOT FOCUS event you put the focus back on the other text box. That gets you out of the context of the original text box.
 
Think about it this way. When you branch to another procedure, you still are within the scope of the procedure which called it. When the called procedure finishes you still come back through the one which called it. Therein lies the problem, I believe. In order to make it work, you would have to set the focus somwhere else and have it send it back. What could work is to have a small, .01 x .01 sized text box on the form and in the after update event you set the focus to it and in the mini text box's GOT FOCUS event you put the focus back on the other text box. That gets you out of the context of the original text box.


Excellent BOB, I hate solutions like this that make sense but you wouldn't think you need to do. So I removed the set focus from the subs, and instead of adding another control I just moved focus to the other control and then immediately back, and this seems to work?


Code:
Private Sub txtMB_AfterUpdate()
    Me.tblRFpick_subform.Form.Requery
    Me.txtMB.SetFocus
    Me.txtUPC.SetFocus
End Sub
 
Private Sub txtUPC_AfterUpdate()
    AppendUPC
    Me.tblRFpick_subform.Form.Requery
    Me.txtMB.SetFocus
    Me.txtUPC.SetFocus
End Sub


also set TAB stop back to YES so I'm not getting a false result
 

Users who are viewing this thread

Back
Top Bottom