Results 1 to 3 of 3
  1. #1
    jonnyuk3 is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2009
    Posts
    4

    Count records in another table

    Hi,

    I have three tables, customer, interest and link_customer_interest. This is to allow for many to many relationships.

    On the interest form i want to be able to count the records in the link_customer_interest table that are relevant to the current interest displayed on the interest form and display this value in a text box.

    Any ideas how i do this.

    Thanks in advance,



    jonnyuk3

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    you can use Dcount:

    My assumptions:
    1) You have Interest_Id which is the unique number of each interest in your table in your link_customer_interest table.
    2) You have a primary key in your link_customer_interest table which I have refered to in my expression as [link_cutomer_interest_Id]
    3) You have the interest_id field on your form, recordsource interest table.


    =iif(isNull(DCount("[link_cutomer_interest_Id]","link_customer_interest","[Interest_ID]=" & Forms!Name of the Form!Interest_ID)),0,DCount("[Link_cutomer_interest_Id]","link_customer_interest","[Interest_ID]=" & Forms!Name of the Form!Interest_ID))

    Please cjange the name of the Fields, Controls and Form with the ones in yor database.

  3. #3
    jonnyuk3 is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2009
    Posts
    4
    Thanks for the reply Maximus, excuse my ignorance but where do i use this code?

    thanks,

    jonnyuk3

    Got it, thanks for your help Maximus.
    I put the code on the onCurrent event of the form, works like a charm.

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

Similar Threads

  1. Count Records
    By Cheshire101 in forum Access
    Replies: 1
    Last Post: 11-30-2010, 03:02 PM
  2. Is it possible for me to count my records? how?
    By radicrains in forum Queries
    Replies: 4
    Last Post: 10-28-2010, 05:28 AM
  3. Query to count records
    By jpkeller55 in forum Access
    Replies: 4
    Last Post: 10-24-2010, 09:24 AM
  4. Count of records
    By Aston in forum Access
    Replies: 2
    Last Post: 03-30-2010, 05:20 AM
  5. Count of records
    By Bruce in forum Forms
    Replies: 3
    Last Post: 03-22-2010, 01:30 PM

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