Changing Bound Text Box Border Width Property Screws Up Tab Order

D

Dan

Hi, I am using Access 2007. I have module sub that is passed the
form's name and it checks to see if control is a text box that just
received focus and if so thickens it border to queue user where
insertion pointer is. The problem is as the user tabs from control
to control the text will disappear in the text box teh got the focus
and reappear on exit from control of a mouse click in it. In addition
the tab order no longing works either. Here is the code:

' This function, HighlightTextbox(), highlights a textbox border to
indicate it has the Focus and de-highlights
' previous object focus if textbox. Since Access cannot trigger this
function on the form level, a call must be made
' in each textbox on the form.
Public Sub HighlightTextbox(strCallingForm As String)

Dim ctrlActive As Control
Dim strActiveControlSource As String
Dim ctrlPrev As Control
Dim strPrevControlSource As String
Dim intRetval As Integer


On Error GoTo HighlightTextbox_Error


'If Forms(strCallingForm).Visible = True Then

'Forms(strCallingForm).AllowEdits = False

Set ctrlActive = Screen.ActiveControl

If TypeOf ctrlActive Is TextBox Then
'ctrlActive.Enabled = False
'strActiveControlSource = ctrlActive.ControlSource
'ctrlActive.ControlSource = ""
'ctrlActive.Locked = True
ctrlActive.BorderWidth = 2
intRetval = DoEvents()
Debug.Print "active", ctrlActive.Name
End If

Set ctrlPrev = Screen.PreviousControl
If TypeOf ctrlPrev Is TextBox Then
'ctrlPrev.Enabled = False
'strPrevControlSource = ctrlPrev.ControlSource
'ctrlPrev.ControlSource = ""
'ctrlPrev.Locked = True
ctrlPrev.BorderWidth = 0
intRetval = DoEvents()
Debug.Print "previous", ctrlPrev.Name
End If

Debug.Print Time, ctrlActive.Name, ctrlPrev.Name
'ctrlActive.Enabled = True
'ctrlPrev.Enabled = True
'ctrlActive.ControlSource = strActiveControlSource
'ctrlPrev.ControlSource = strPrevControlSource
'ctrlActive.Locked = False
'ctrlPrev.Locked = False
'Forms(strCallingForm).AllowEdits = False

'End If

Exit Sub

HighlightTextbox_Error:

Exit Sub

End Sub

How can I get Access to behave properly? I am assuming I have to
suspend the Control Source in some fashion but tried many ways with no
luck. TIA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top