Results 1 to 4 of 4
  1. #1
    aggiemarine07 is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2012
    Posts
    3

    Count question

    I have a probably very silly question but I cant seem to find an answer anywhere on the forum.

    Is it possible to count the number of instances within a ROW instead of a column?

    For example



    ID | Name | Location | Name | Location
    1 Smith BAS Johnson BAS
    2 Jones Hosp Williams Hosp

    Using the above information, I would like to use a formula/VBA to count the total times BAS appears within a row in a specified table (i.e. BAS = 2 or Hosp = 2). Is that possible? Thanks.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    It is not exactly what you are looking for but here is an example of enumerating each Column of a recordset by its Field index and name.
    https://www.accessforums.net/queries...tml#post224203

    There are other examples out there but, that was the first one that I found that was simple and straight forward.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    you could run query with sub queries... Q1 query the 1st ID,NAME/LOCATION,
    a 2nd qry to get ID, NAME2, LOCATION2,
    a 3rd qry that is a UNION qry of Q1 & Q2,
    and a 4th qry does the count.
    Simply run Q4, (this will in turn run, q3, which runs Q1 & 2.)

  4. #4
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    Are there only two columns to look at, or are there more?

    If there are only two, and you are looking for rows where the counts are = 2, then just look for Location1 = location2 and location1 = "BAS".

    If you have more than 2 columns, then you should look at redesigning your data - it is not properly normalized.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Using Count, Group By, and MOD question
    By BrockWade in forum Queries
    Replies: 3
    Last Post: 02-11-2014, 12:52 PM
  2. question|count table
    By mikichi in forum Access
    Replies: 2
    Last Post: 10-29-2013, 11:31 AM
  3. Another unique count question
    By atran in forum Reports
    Replies: 2
    Last Post: 05-24-2012, 10:18 AM
  4. Question; Count function ..
    By efleming in forum Queries
    Replies: 4
    Last Post: 05-27-2011, 08:05 AM
  5. Inventory Count and Receiving Question
    By daniels31790 in forum Access
    Replies: 0
    Last Post: 02-24-2010, 01:33 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums