TextBox disappears behind OLE object control

An Access 2007 database has a form with 6 tabs; tab 6 in this form has an OLE object control and a TextBox control; the TextBox control is in front of the OLE object control; the OnCurrent event in the form uses the move method to move the TextBox control. The previously active control must remain active when the OnCurrent event fires.

Problem: When any tab other than tab 6 is active and the OnCurrent event fires, the TextBox disappears behind the OLE object (which can be seen when you go back to tab 6); the TextBox must remain in front of the OLE object.

Unsuccessful solutions:
-docmd.runcommand bringtofront - can not be run unless form is in design view, apparently.
-Tried ctrl = activecontrol, TextBox.SetFocus, ctrl.setfocus in the OnCurrent event; have not been able to set a variable as activecontrol. I have tried many different little variations of this, but none have been able to grab activecontrol.
LVL 3
burtfacemanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

puppydogbuddyCommented:
Here is how you grab the active control......code from the tips page of www.aadconsulting.com

The ActiveControl object does not have a Name property, so you need to use the Control object class:

Function GetActiveCtlName() As String
__Dim ctlCurrentControl As Control
__Set ctlCurrentControl = Screen.ActiveControl
__GetActiveCtlName = ctlCurrentControl.Name
End Function


0
burtfacemanAuthor Commented:
@puppydogbuddy:  I've tried that.  I've tried Me.ActiveControl, Screen.ActiveControl, Forms("FormName").ActiveControl, and a whole bunch of other variations, each time with the VBA code window closed.  I guess there is no active control during the OnCurrent event.

The solution ended up being something so stupid and easy that I had to bang my head on my desk: it's all in the tab order of the objects!  I just had to move my TextBox object after the OLE Object in the form's tab order!

Hopefully someone else runs into this obscure little problem and can benefit from what I learned!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.