Form textbox default value - self reference

way2bord

Registered User.
Local time
Today, 08:09
Joined
Feb 8, 2013
Messages
177
I want to refer to an objects properties in form: ie...
set a textbox's default value = textbox.name (me.name?)

How do I set this in the form's default value (...without using VBA).
 
How do I set this in the form's default value (...without using VBA).
I do not believe that is possible. I believe you need to use VBA for that. One thing to note. Macros do not duplicate everything that VBA can do. Sometimes, if you want to do something, you have to use VBA.
 
Drats. Current work around is below -- if anyone could reccommend better, please do so.

Public Function that returns the name of the activecontrol. Default value = FunctionCall()
 
Perhaps I have not understood your requirement but if you create a text box called "MyTxtBox" and then set its Default property to:
=[MyTxtBox].[Name]
it shows:
MyTxtBox
in a new record.
 
Perhaps I have not understood your requirement but if you create a text box called "MyTxtBox" and then set its Default property to:
=[MyTxtBox].[Name]
it shows:
MyTxtBox
in a new record.

I have 100 txtboxes. They're labeled "MyTxtBox001", "MyTxtBox002",..."MyTxtBox100"

I want to use a defaulted formula "=[Name]" or "=ActiveObject.[Name]" or something to that affect.
 
I can't think of any way to do this by just setting the default property.
Is there something wrong with the idea of using a function.
Another way might be to use some code in the forms On Current or On Open event to set the Default properties.
 
I think you could use something like:
Code:
Private Sub Form_Open(Cancel As Integer)
Dim ctrl As Control

    For Each ctrl In Me.Controls
        If ctrl.ControlType = acTextBox Then
            ctrl.DefaultValue = "='" & ctrl.Name & "'"
        End If
    Next
End Sub
 

Users who are viewing this thread

Back
Top Bottom