TextBox disappears behind OLE object control

Posted on 2010-03-26
Medium Priority
Last Modified: 2013-11-29
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.
Question by:burtfaceman
LVL 38

Expert Comment

ID: 28791293
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


Accepted Solution

burtfaceman earned 0 total points
ID: 28988509
@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!

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question