What is the difference between CONTROL.value and CONTROL.text ?
I still can't understand the difference.
I have done searches, and read through what Microsoft has to say and I still don't get it.
Thanks.
Ken L
What is the difference between CONTROL.value and CONTROL.text ?
I still can't understand the difference.
I have done searches, and read through what Microsoft has to say and I still don't get it.
Thanks.
Ken L
Use .text to get what's being written in "real time", usually within a change event. Just make sure your control has focus. Test both value and .text within a change event to know what I'm saying.
You'll notice that .value is:Code:Private Sub YourControl_Change() Debug.Print YourControl.Text, YourControl.Value End Sub
If new record = null
If existing record = the value when you opened the form or the value when you navigated to that record
But .Text is the current content of the control.
Put another way
.Text is the unsaved version of what a textbox contains.
.Value is what was last saved in the record. It may or may not be the same as what the underlying field contains.
It's not the same when you have unsaved edits...
?forms![attendance log1].DateV.value
1/02/27 4:00:00 AM
?forms![attendance log1].DateV.text
1/02/2027 4:00:00 PM
IIRC, that means the control has to be bound, otherwise there would be no distinction between the two. M$ documentation does not make that distinction but it makes sense to me. Lastly, a control has to have the focus in order to get/set its .Text property.
And for those wondering, the object names from this db are not of my creation.
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
I would also throw in
.value is the default property of a control and does not need to be specified
there is another property .oldvalue
this is only populated with bound controls and contains the value when the form is first loaded
so the sequence might be
form is loaded- oldvalue and value contain the value of the underlying field
user clicks on the control (it has the focus) - the text property is assigned the value which user can edit.
User leaves the control (loses focus)- value is assigned the text value and the text property is no longer available
Note that for certain field types such as dates are stored as numbers - that is what will be in the oldvalue and value properties, text shows the text format of that numeric value so you can edit it