Get Record Count Number by Macros

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dear all,

Is it possible to get the numbers of records from a query / table by using
Macros?

Thx in advanced.
 
Florence,

No, this is not a job for a macro. You can get the number of records
via a Totals Query, using Count. Or you can use a DCount function, for
example DCount("*","YourTable"). If you need more explicit help, can
you explain a bit more detail about how and where you need to use this
figure?
 
Dear Steve,

Yes of course.

I have a text file exported by a query which is working fine by using Macros.

Now I need to insert 1 line at the end of the text file showing the total
number of records included in this text file. For example, if 100 records in
the query, the text file from line 1 to 100 will be these record lines and
then at the line 101, I need to put a string "END 101".

So I need to have another query getting the number of records first? Any
other alternatives are appreciated.

Thanks!
 
Florence,

It is possible to use a VBA procedure to open and write to the text file
itself, after the detail records have been exported to it.

Apart from that, the only way I can think of to achieve this is to
export from a Union Query. This would potentially be a lot easier, but
depends on the structure of the text file being exported. For example,
if you are exporting from a multi-field query, and the text file has
comma delimiters between the fields, then the Union Query would need to
export the same number of fields for the last line as well, so you will
end up with the same number of commas after the "END 101" as there are
fields in the main query, if you see what I mean.
 
Steve,

Yes, I got what you mean. And I don't want to have the same number of comma
delimiters for the last line.

I think I have to rewrite it by VBA.

Thanks anyway.
 
Back
Top