Word Count

M

Martin

I have an unbound field that is a memo field type. As the user types in
characters I want to have another unbound field counting the length of the
memo field. I know this can be done but I can't think how to do it. Do I
need some code on the memo field updating the word count field using 'On Key
Press'?

Any help would be greatly appreciated.

Martin
 
S

Stuart McCall

Martin said:
I have an unbound field that is a memo field type. As the user types in
characters I want to have another unbound field counting the length of the
memo field. I know this can be done but I can't think how to do it. Do I
need some code on the memo field updating the word count field using 'On
Key
Press'?

Any help would be greatly appreciated.

Martin

There's no such thing as an unbound field. You can have an unbound control
on a form, but then because it's unbound it cannot have a data type, memo or
otherwise.

So I'm going to presume you have an unbound textbox called text1 on a form.
Create another textbox to display the character count, then set it's
ControlSource property (directly in the property sheet) to:

=Len([text1])
 
M

Martin

Stuart,

Apologies I did mean text box. I have done that and that counts as it
should but I would like it to update everytime a character is added to the
memo text box.

Any ideas?

Martin

Stuart McCall said:
Martin said:
I have an unbound field that is a memo field type. As the user types in
characters I want to have another unbound field counting the length of the
memo field. I know this can be done but I can't think how to do it. Do I
need some code on the memo field updating the word count field using 'On
Key
Press'?

Any help would be greatly appreciated.

Martin

There's no such thing as an unbound field. You can have an unbound control
on a form, but then because it's unbound it cannot have a data type, memo or
otherwise.

So I'm going to presume you have an unbound textbox called text1 on a form.
Create another textbox to display the character count, then set it's
ControlSource property (directly in the property sheet) to:

=Len([text1])
 
S

Stuart McCall

Martin said:
Stuart,

Apologies I did mean text box. I have done that and that counts as it
should but I would like it to update everytime a character is added to the
memo text box.

Any ideas?

Martin
<SNIP>

Try putting:

Me.ReCalc

in the textbox's OnChange event. That forces all calculated controls to be
evaluated and re-displayed.
 
M

Martin

Hi,

That does recalc the total but also loses the text entered in the memo field
so the count is always at 1
 
F

fredg

Hi,

That does recalc the total but also loses the text entered in the memo field
so the count is always at 1

No need to recalc or refresh.

First add another unbound control to display the count in.
Then ...
Place the following code in the Memo control's Change event:

Me.([CountControlName]) = Me.([MemoControlName].Text)

As you enter the new text, the value in the Count control will
increment.
The new text does not become the Memo control's Value until you save
the record. That's why counting the Text property works while counting
the Memo Control's Value does not.
 
J

John Spencer

I think you may have to push the value to the control displaying the length
from the control where you are entering data using the on change event of
the control where you are entering the data.

Me.ShowLength = Len(Me.EnterData.Text & "")

If you want the length to show when you enter the form, use the form's
current event to set the value
Me.ShowLength= Len(Me.EnterData.Value & "")


--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
S

Stuart McCall

Martin said:
Hi,

That does recalc the total but also loses the text entered in the memo
field
so the count is always at 1

Huh? Never heard of that before. Still, there's always more than one way.
Delete the character-count textbox's ControlSource, lose the Me.ReCalc. Put
this code in the memo textbox's OnKeyPress event (assuming the char-count
textbox is called text2) :

Me.text2.Value = Len(Me.text1.Text)
 
M

Martin

Fredg, this works perfectly, thank you so much.

Martin

fredg said:
Hi,

That does recalc the total but also loses the text entered in the memo field
so the count is always at 1

No need to recalc or refresh.

First add another unbound control to display the count in.
Then ...
Place the following code in the Memo control's Change event:

Me.([CountControlName]) = Me.([MemoControlName].Text)

As you enter the new text, the value in the Count control will
increment.
The new text does not become the Memo control's Value until you save
the record. That's why counting the Text property works while counting
the Memo Control's Value does not.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top