Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Put number of records in a variable (MSACCESS 2003)

    I am using a quick way to count the number of records there are in a table, using the listcount of a list. However I know that not very efficient or professional. Is there a better way in code Many thanks

    MySql = "SELECT * FROM TXCLIPS"
    MySql = MySql & " WHERE (((TXCLIPS.ID1)=[FORMS]![Mainform1].[FORM].[ID1])) "
    Me.LBC.RowSource = MySql

    ND=ME.LBC.LISTCOUNT

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Put number of records in a variable (MSACCESS 2003)

    Try
    <code>
    ND = DCount("*", "TXCLIPS", "ID1=Forms!MainForm1!ID1")
    </code>
    The DCount function can be used to count the number of records in a table or query that satisfy the specified criteria.

  3. #3
    4 Star Lounger
    Join Date
    Feb 2008
    Location
    United Kingdom
    Posts
    490
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Put number of records in a variable (MSACCESS 2003)

    Thanks very much Hans, perfect. Regards

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Put number of records in a variable (MSACCESS 2003)

    DCount is one of the domain aggregate functions. Among the others are DLookup, DSum, DMin, DMax and DAvg. They all have the same syntax. Look them up in the Access VBA help or see DCount Function [Access 2003 VBA Language Reference].

Posting Permissions

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