Calculations w/ table data

  • Thread starter Thread starter JG
  • Start date Start date
J

JG

I know this may seem simple, but I can't find any examples
in any of the books I have. I want to program a form
where the user will select a table from a list of all
tables in a database. I then need the compiler to find
the number of rows in the table, divide it by three, and
then take averages of the three sections (i.e. if there's
90 rows, I need the average of row 1-30, 31-60, and 61-
90). I need to know the syntax to make this happen.
Thank you so much in advance.
john
 
Ok. Not sure if this works because I haven't tested it
but:

Create a query with this SQL statement:
SELECT MSysObjects.Name FROM MSysObjects WHERE
(((MSysObjects.Type)=1));

Using DAO or ADO, open the query as a recordset (rstQuery)

Use a loop to loop through each record in the query.

Set rstCurrentTable = rstQuery!Name
rstCurrentTable.MoveLast
rstCurrentTable.MoveFirst

x = rstCurrentTable.RecordCount

'Calculations go here

rstCurrentTable.close
Set rstCurrentTable = Nothing
'***************************************

From here, you should be able to do your calculations.
The RecordCount is, (obviously) the number of records in
the table, which is also the number of rows.

Hope this helps,
Crystal
 
Back
Top