Hi,
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
as you can see by the highlighted code it should focus the field and set the carret position , only it doesn't?
Why?
If I placed right at the end of the inputZoom function
I get
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?
Thanks,
1DMF.
"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music Download
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
Code:
=inputZoom("Notes")
The function is this..
Code:
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
Else
Set ctl = Screen.ActiveControl
End If
If ctl.Parent.Recordset.Updatable Then
DoCmd.RunCommand acCmdSaveRecord
End If
DoCmd.OpenForm "inputPopUp", acNormal, , , , , sTitle
Forms("inputPopUp").BindControl ctl
End Function
the BindControl sub does this
Code:
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
Loop
Set oControl = BoundControl
Set Me.Recordset = ctl.Recordset
With zoomCtl
.ControlSource = BoundControl.ControlSource
.Locked = BoundControl.Locked
.ValidationRule = BoundControl.ValidationRule
.ValidationText = BoundControl.ValidationText
.Format = BoundControl.Format
.ControlTipText = BoundControl.ControlTipText
.ForeColor = BoundControl.ForeColor
End With
[b]
Me.inputTextBox.SetFocus
If Not IsNull(Me.inputTextBox) Then
Me.inputTextBox.SelStart = Len(Me.inputTextBox)
Else
Me.inputTextBox.SelStart = 0
End If
[/b]
Exit Sub
errlbl:
MsgBox err.Number & " " & err.Description
Exit Sub
End Sub
as you can see by the highlighted code it should focus the field and set the carret position , only it doesn't?
Why?
If I placed right at the end of the inputZoom function
Code:
msgbox Screen.ActiveControl.Name
I get
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.inputTextBox
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?
Thanks,
1DMF.
"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music Download