R
Reader1
Hello,
I posted a question earlier regarding a calculated field to use on a form.
Graham Mandeno was kind enough to reply with the folling advice .....
<Quote>
===========================================================
The property that changes as you type is the Text property, but this is only
available when the textbox has the focus.
So the short answer is that you cannot use a calculated control for this,
but you must use an unbound control and fill it with the calculated value
using code.
The Change event is the one that is raised repeatedly as you type, so you
need some code like this:
Private Sub MyTextBox_Change()
txtNumChars = Len(MyTextBox.Text)
End Sub
You will also want the value to be correctly set as you navigate from one
record to another, so use the Current Event:
Private Sub Form_Current()
txtNumChars = Len(MyTextBox & "")
End Sub
The & "" bit handles the situation where the value in the textbox is Null.
===========================================================
<Unquote>
I don't really know what I'm supposed to do with this code but here's what
I've done so far........
My table is called 'tbl_Test'
It contains two fields 'Alpha' and 'Beta'
Both text fields
My form is called 'frm_Test3'
It has two fields - Alpha and Beta
(It's the Alpha field that I want to count the number of characters)
I've added a third unbound text box called 'MyTextBox'
In the properties for this field where it says 'On Change' next to this it
says [Event Procedure]
If I click on the [...] (three dots field) that's where I pasted the
following
Private Sub MyTextBox_Change()
txtNumChars = Len(MyTextBox.Text)
End Sub
Then on the form properties where it says 'On Current' next to this it says
[Event Procedure]
If I click on the [...] (three dots field) that's where I pasted the
following
Private Sub Form_Current()
txtNumChars = Len(MyTextBox & "")
End Sub
It doesn't work so what have I done wrong ?
(I'm a newbie at this)
Apologies for second post but my first post had the same subject heading and
is now mixed in with another post.
I posted a question earlier regarding a calculated field to use on a form.
Graham Mandeno was kind enough to reply with the folling advice .....
<Quote>
===========================================================
The property that changes as you type is the Text property, but this is only
available when the textbox has the focus.
So the short answer is that you cannot use a calculated control for this,
but you must use an unbound control and fill it with the calculated value
using code.
The Change event is the one that is raised repeatedly as you type, so you
need some code like this:
Private Sub MyTextBox_Change()
txtNumChars = Len(MyTextBox.Text)
End Sub
You will also want the value to be correctly set as you navigate from one
record to another, so use the Current Event:
Private Sub Form_Current()
txtNumChars = Len(MyTextBox & "")
End Sub
The & "" bit handles the situation where the value in the textbox is Null.
===========================================================
<Unquote>
I don't really know what I'm supposed to do with this code but here's what
I've done so far........
My table is called 'tbl_Test'
It contains two fields 'Alpha' and 'Beta'
Both text fields
My form is called 'frm_Test3'
It has two fields - Alpha and Beta
(It's the Alpha field that I want to count the number of characters)
I've added a third unbound text box called 'MyTextBox'
In the properties for this field where it says 'On Change' next to this it
says [Event Procedure]
If I click on the [...] (three dots field) that's where I pasted the
following
Private Sub MyTextBox_Change()
txtNumChars = Len(MyTextBox.Text)
End Sub
Then on the form properties where it says 'On Current' next to this it says
[Event Procedure]
If I click on the [...] (three dots field) that's where I pasted the
following
Private Sub Form_Current()
txtNumChars = Len(MyTextBox & "")
End Sub
It doesn't work so what have I done wrong ?
(I'm a newbie at this)
Apologies for second post but my first post had the same subject heading and
is now mixed in with another post.