Creating a log

dcarr

Trainee Database Analyst
Local time
Today, 07:27
Joined
Jun 19, 2002
Messages
112
I have a form that contains multiple buttons. One of the buttons runs a macro, that runs a query to import a set of records from a CSV file. I need to create a piece of code that counts the number of records, does a sum of the total, and places a date time stamp on the values. I need this to be kept in a log file somewhere? Is this possible?
 
First let me ask you this... do you have a field in your table that is unique to each file that is imported? Like an Import Date field? If not you could create one at the end of the table and just set the default value to Date().

Once you have something like this you can create a log table with 2 fields Date/Time Stamp & Total.

Then create an append query add the table that you import the data into and append to the log table. Right click in the field area and click totals.

For the first field put:
Field = Date Stamp: Now()
Total = Expression
Append To = Date/Time Stamp

For the second field put:
Field = Choose the date field that you added to the table you are importing to.
Table = The name of the table you import to
Total = Count
Append To = Total
Critteria = Date()

Now in your macro add an openquery choose the append query you just created make sure the view is Datasheet and the data mode is Edit.

When you run the macro it will import the data placing today's date in the field that you created at the end, then it will run the update query counting all the records in your table with that date and will put the time and date with the total in your log table.

I hope this helps.
 

Users who are viewing this thread

Back
Top Bottom