New call-to-action
Results 1 to 8 of 8

Thread: count records

  1. #1
    "Certified" Alphaholic
    Real Name
    Charlie Crimmel
    Join Date
    Apr 2000
    Location
    West Virginia
    Posts
    1,695

    Default count records

    Count Records:
    I am trying to count records in a database and return the record count to the screen.
    Problem:
    the screen is attached to a table called zztime
    which has 1 record.
    I am trying to count the records in two tables.
    One called timentry (which has 78 records)
    and the other called timehist which has 100 record.
    If I run the following script from the control panel and then view the trace window, sometimes I get the correct answer. Sometimes the time history count returns the time Entry record count.
    When I run it from the menu I always get a record
    count of 1
    Any Ideas
    Charlie Crimmel

    ' ---------Script for Count Timentry ------------
    dim global tereccount as N
    tereccount=0
    trace.clear()
    t2 = table.open("timentry.dbf")
    var->tereccount=reccount()
    trace.writeln ("Timentry Records "+ str(var->tereccount))
    trace.writeln ("--------------------------------------")
    t2.close()

    end:
    end

    ' ---------Script for Count Time History ------------
    dim global threccount as N
    threccount=0
    trace.clear()
    t3 = table.open("timehist.dbf")
    var->threccount=reccount()
    trace.writeln ("Time History Records "+ str(var->threccount))
    trace.writeln ("--------------------------------------")
    t3.close()

    end:
    end




  2. #2
    "Certified" Alphaholic
    Real Name
    JohnZaleski
    Join Date
    Oct 2000
    Posts
    1,736

    Default RE: count records

    Try this:
    var->tereccount= t2.records_get()

  3. #3
    "Certified" Alphaholic
    Real Name
    Charlie Crimmel
    Join Date
    Apr 2000
    Location
    West Virginia
    Posts
    1,695

    Default RE: count records

    John:
    That works if I run the script from the control panel
    But if I run it from the menu I get a reccount =1
    Charlie crimmel

  4. #4
    "Certified" Alphaholic
    Real Name
    JohnZaleski
    Join Date
    Oct 2000
    Posts
    1,736

    Default RE: count records

    Charlie,

    The following script is an example of something that shoule work no matter where it is run from:

    tb1 = table.open("timetrx")
    count = tb1.records_get()
    tb1.close()
    ui_msg_box("Answer",str(count))

    When you used the reccount() function it assumed the current table which was the table for your form with probably one record in it.
    John

  5. #5
    Member
    Real Name
    Stephen Williams
    Join Date
    Apr 2000
    Location
    Oakland, CA
    Posts
    930

    Default RE: count records

    Charlie -
    A comment on Johns method - He is actually counting records in the currently active INDEX, which is not necessarliy the same as the number of records in the table. If the currently active index is recno() they will be the same. If you are looking at the table as it is linked in a set it will only count the linked child records as the index used by the set will be the active index.

    Johns method is the one I use, as it gives me what I actually want. But the count can vary depending on the active index...

  6. #6
    Member
    Real Name
    Stephen Williams
    Join Date
    Apr 2000
    Location
    Oakland, CA
    Posts
    930

    Default RE: count records

    Oops - shot from the lip again!
    John has a table pointer, so he IS counting records in the table.

    Now I am getting into deeper water but... if you want the indexed record count from within a set try
    t = topparent:tables:timentry.current()' gets a pointer to the current status of timentry table
    i = t.index_primary_get()'gets a file pointer the active index (or query)
    count = i.records_get()'counts the records

  7. #7
    "Certified" Alphaholic
    Real Name
    Charlie Crimmel
    Join Date
    Apr 2000
    Location
    West Virginia
    Posts
    1,695

    Default RE: count records

    The timeentry and time history tables are not in a set.
    They are not even attached to my menu
    The table on the menu is a dummy table with 1 record.
    from that menu I want to count records in other tables.
    this is to give me record counts before and after an append operation.
    Charlie Crimmel

  8. #8
    "Certified" Alphaholic
    Real Name
    Charlie Crimmel
    Join Date
    Apr 2000
    Location
    West Virginia
    Posts
    1,695

    Default RE: count records

    Thanks All:
    I got it to work.
    I used your suggestions.
    Must have had a corrept script.
    Deleted it and re-wrote it from scratch and it worked.

    sample that worked:
    ' count timentry
    dim global tereccount as N
    tereccount=0
    trace.clear()
    t2 = table.open("timentry.dbf")
    var->tereccount=t2.records_get()
    t2.close()
    trace.writeln ("Time Entry Records " )
    trace.writeln ("Time Entry Records "+ str(var->tereccount,10))
    trace.writeln ("--------------------------------------")

    end:
    end

Similar Threads

  1. Count records
    By Amateur in forum Alpha Five Version 5
    Replies: 11
    Last Post: 09-12-2004, 07:44 PM
  2. Count records in report
    By dcorcoran in forum Alpha Five Version 5
    Replies: 3
    Last Post: 02-28-2004, 09:46 PM
  3. Query Records Count
    By David Agan in forum Alpha Five Version 5
    Replies: 2
    Last Post: 10-04-2002, 12:08 PM
  4. Count records in a query
    By Jamin Dunivan in forum Alpha Five Version 4
    Replies: 5
    Last Post: 04-17-2001, 11:33 AM
  5. Count of records.
    By Rodney Efird in forum Alpha Five Version 4
    Replies: 1
    Last Post: 05-17-2000, 06:34 AM

Bookmarks

Posting Permissions

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