473,395 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Word Count in a Form

Hi

Does anyone know if it is possible to display a word count as and when
a user is inputting text into a memo field on a form. The code I'm
using below is fine when applied to the 'On Exit' event but ideally I
would like it to be dynamic. I've tried the other events for the Memo
field but none seem to do it.
-----------------------------------------------------------------
Private Sub Personal_Comments_Exit(Cancel As Integer)

If IsNull(Me![Personal Comments]) Then Exit Sub
' cut off spaces before and after memo words
strMemo = Trim(Me![Personal Comments])
' initialize all variables
intCountWords = 0
intSpaces = 0
intAllSpaces = 0
' do only if there is at least one word
If Not IsNull(strMemo) Then
'Stop
' add 1 as there must be at least one word so far
intCountWords = intCountWords + 1
Do
intAllSpaces = intAllSpaces + intSpaces
intSpaces = InStr(1, strMemo, " ") ' Find space.
strMemo = Trim$(Right$(strMemo, Len(strMemo) - intSpaces))
intCountWords = intCountWords + 1
Loop Until InStr(1, strMemo, " ") = 0
End If
Me!txtCount = intCountWords
txtCount.Requery

End Sub
------------------------------

thanks

David

May 22 '06 #1
1 2489
The only other somewhat simple way is on the on keydown event check to
see if it is a space and if the previous keystroke was not a space then
count 1 word. At end add 1 and you have word count.

However, I don't believe this will work with cut and past, nor
backspacing over a word and adding two words. and other such keyboard
antics.

I think what you have already, is as close as you are going to get
without some significant analysis and design.

Ron

May 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: The Roys | last post by:
Hi Im doing something wrong in quitting the Word.Application in my VB program. I have General Declarations Dim AppWord As Word.Application Form_Load() Set AppWord =...
5
by: Alistair | last post by:
Hello folks... this is my first post in here. I'm new to ASP having done all my previous work in Flash and bog standard HTML. Only been learning for a couple of weeks. anyway...I have been...
1
by: reneecccwest | last post by:
Hello, can anybody share the code for a word counter for the textarea user input? what if max characters are 256? thanks
3
by: Phil Rutter | last post by:
Hello All, I have about 700 word documents that have 2 tables one is static 4 colums x 5 rows the other is 5 colums x rows ranging from 2 to 100 what i wolud like to do is open the word doc....
8
by: Darryl Kerkeslager | last post by:
I hope that although this is 25% Access and 75% Word, that someone will know ... The whole problem here arises because 1) Microsoft acknowledges an 'issue' wherein TextInput type FormFields are...
1
by: trihanhcie | last post by:
Hi I have several textarea in the same page. I would like to count the words in each textarea without any interaction with each other. Here's the code I used for the count : <script...
0
southoz
by: southoz | last post by:
Good ay all , I'm fairly new to access(a little over 5 weeks now). Since I'v started I have picked up a lot of useful information from forums such as this and in doing so will share that information...
1
by: Darsin | last post by:
What i am doing is to pull the data from a CMS and import it to Word 2007 Beta and i also have to export the data from Word 2007 Beta back to that CMS. We have with us two Web Services of the CMS....
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
4
by: FunkHouse9 | last post by:
I built a form that is depentent on a word count a word count. What I have works just fine in IE but doesn't work in Firefox. It changes the count from 0 to 1 and that's as far as it goes. Here's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.