Can I do this - so all text box box controls could send their name to a shared UDF?
Thanks.
Can I do this - so all text box box controls could send their name to a shared UDF?
Thanks.
Yes. Send any value you want. Call the function from Click or AfterUpdate event property.
Example of calling a function from a button Click event:
=HandleButtonClick(1)
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Sorry i meant one function for all, not duplicated for each control.
I have found something -
However I'm stumped as although I'm passing the control Name, what arrives is the control value.Code:Private Sub Form_Load() Dim ctl As Control For Each ctl In Me If ctl.ControlType = acTextBox Then ctl.OnDblClick = "=doubleclick([" & ctl.Name & "])" End If Next ctl End Sub Function doubleClick(x) As String Debug.print x End Function
If you want doubleClick() to output the control name as a literal string, remove the [] and use apostrophes instead. The brackets define an object reference which is why you get the value from current record when you dblClick the textbox.
Or if doubleClick is behind the form, leave the brackets and change code to:
Debug.Print Me.Controls(x.Name).Name
Or in any module:
Debug.Print Forms(CurrentObjectName).Controls(x.Name).Name
What do you eventually really want to happen when textbox is double clicked?
My example sets the event property in design. Why are you setting property during runtime?
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Thanks for the tip about apostrophes !
>Why are you setting property during runtime?
There's a lot of text boxes and this one procedure works for all of them.
Yes, a lot of textboxes but in design set it once and done.
Did some edits on my previous post.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.