I seem to be banging my head on a wall that is focusing a field and placing the carret at the end of the line.
I have the following code in a click event
the function is this
the BindControl sub does this
Public Function inputZoom(sTitle As String, Optional ByRef CTRL As Variant)
On Error Resume Next
Dim ctl As Access.Control
If Not IsMissing(CTRL) Then
Set ctl = CTRL
Set ctl = Screen.ActiveControl
If ctl.Parent.Recordset.Updatable Then
DoCmd.OpenForm "inputPopUp", acNormal, , , , , sTitle
as you can see by the highlighted code it should focus the field and set the carret position , only it doesn't?
Public Sub BindControl(BoundControl As Access.TextBox)
On Error GoTo errlbl
Dim zoomCtl As Access.TextBox
Dim ctl As Object
Set zoomCtl = Me.inputTextBox
Set ctl = BoundControl.Parent
Do While Not TypeOf ctl Is Access.Form
Set ctl = ctl.Parent
Set oControl = BoundControl
Set Me.Recordset = ctl.Recordset
.ControlSource = BoundControl.ControlSource
.Locked = BoundControl.Locked
.ValidationRule = BoundControl.ValidationRule
.ValidationText = BoundControl.ValidationText
.Format = BoundControl.Format
.ControlTipText = BoundControl.ControlTipText
.ForeColor = BoundControl.ForeColor
If Not IsNull(Me.inputTextBox) Then
Me.inputTextBox.SelStart = Len(Me.inputTextBox)
Me.inputTextBox.SelStart = 0
MsgBox err.Number & " " & err.Description
If I place this at the end of the inputZoom function
so the correct field is active, and what's even more bizzare to me is when I click 'OK' the field then has the correct focus and the carret is at the end of the line.
Take away that debug statement, it doesn't work, keep the debug statement, it works?
I'm baffled as to why it is behaving like this, can any one help explain why and how I fix it?