Question:

In access, how can i count how many times a specific word has been entered in a form?

by  |  earlier

0 LIKES UnLike

I don't want to count how many records, just like how many times the word appears in that form in one record

 Tags:

   Report

1 ANSWERS


  1. Here's one solution:

    Function Count(SearchWord As String)

      Dim ctrl As Control

      Dim i As Long, varw

      i = 0

      On Error Resume Next

      For Each ctrl In Forms![frmX]

        varw = ctrl.OldValue

        If (varw = SearchWord) Then i = i + 1

      Next

     Count = i

    End Function

    Will count the occurrences of SearchWord in different controls on the form frmX

    On Error Resume Next is added to avoid an error when a non-text control is encountered

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions