Hello World.
I have a little piece of code that I'm trying to convert for use in a module so that it works on any control.
It basically selects all text in a box/field onMouseUp, but I want it to work without having to specify which control all the time
The basic code is:
and here's what I came up with:
The above code gives me a runtime 2450 error, which is bascially 'form not open' - despite the fact it is indeed open
Any suggestions or ideas?
I have a little piece of code that I'm trying to convert for use in a module so that it works on any control.
It basically selects all text in a box/field onMouseUp, but I want it to work without having to specify which control all the time
The basic code is:
Code:
Me.{controlname}.SelStart = 0
Me.{controlname}.SelLength = Len(Me.{controlname}.Text)
Code:
Public Function SelectAll()
Dim strActiveCtl As String
Dim strActiveForm As String
strActiveCtl = Screen.ActiveControl.Name
strActiveForm = Screen.ActiveForm.Name
'use forms!myformname rather than me.
'Forms!strActiveForm!strActiveCtl.SetFocus
Forms!strActiveForm!strActiveCtl.SelStart = 0
Forms!strActiveForm!strActiveCtl.SelLength = Len(Form!strActiveForm!strActiveCtl.Text)
End Function
Any suggestions or ideas?
