Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Posts
    16

    Unanswered: count certain words in memo field

    I have a memo field that contains a large string of text with newline chars at the end of each line.
    I am trying to figure out a way to analyze that string line by line.

    for example:
    one line might tell me that there was a miscount in the number of cartons, tell me the old number (54) and then tell me the number was corrected to (56).

    I would like to be able to say something along these lines:
    Search the string for a count of the number of times the word "carton" was found.
    Because of the uniformity of the way the strings are brought into the memo field I know that the word "carton" for a typical error would be displayed twice - therefore I can take the count of the number of times "carton" was found, divide it by 2, and know the number of carton errors I had.

    I understand code fairly well, but have not worked with it in a couple years so I do not know the best approach to take within access to accomplish this. I was thinking there would be some way to build an expression in the expression builder or a macro or module?? Also what is the common language used to interact with Access - VB? or can I use one of a few different languages?

    Thanks for the help!

  2. #2
    Join Date
    Jan 2004
    Posts
    75

  3. #3
    Join Date
    Oct 2003
    Location
    Roanoke, Va
    Posts
    445

    Smile Re: count certain words in memo field

    Originally posted by cavall
    I have a memo field that contains a large string of text with newline chars at the end of each line.
    I am trying to figure out a way to analyze that string line by line.

    for example:
    one line might tell me that there was a miscount in the number of cartons, tell me the old number (54) and then tell me the number was corrected to (56).

    I would like to be able to say something along these lines:
    Search the string for a count of the number of times the word "carton" was found.
    Because of the uniformity of the way the strings are brought into the memo field I know that the word "carton" for a typical error would be displayed twice - therefore I can take the count of the number of times "carton" was found, divide it by 2, and know the number of carton errors I had.

    I understand code fairly well, but have not worked with it in a couple years so I do not know the best approach to take within access to accomplish this. I was thinking there would be some way to build an expression in the expression builder or a macro or module?? Also what is the common language used to interact with Access - VB? or can I use one of a few different languages?

    Thanks for the help!
    VBA(Visual Basic for Applications)is what it is referred to but is basically (no pun intended) VB hosted in Access. There are some differences but the language elements that you seem to need are all there. I would suggest reading up on the InStr, Mid, Left, and Right functions, but mainly InStr for what you need to do. InStr returns a Variant (Long) specifying the position of the first occurrence of one string within another. You would initially begin your search from the beginning of the text and if an occurrence of your search word was found, you could increment a counter variable and then continue from that point in the text until you reached the end.
    That's rough I know but you said you could work with code so I'll leave the details to your imagination.

    Hope this helps.

    Gregg

  4. #4
    Join Date
    Feb 2004
    Posts
    16

    thanks

    Thanks for the advice guys... appreciate it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •