Hi Experts,
I'm hoping someone may be able to assist me here. I have two tables, one which has data imported into it and the other that will store statistics based on the information in the imported data. My tables are named as follows:
tblTextFilesImported
tblIndividualStats
In the tbleTextFiles Imported I have three fields that I want to target as follows:
dtmScannedBatchDate
strUserName
strScannedBatchNo
I want to calculate the number of records per strUserName per strScannedBatchNo and the dtmScannedBatchDate.
All of the fields above can have variable data in them, that is to say for instance the strUserName "forda" can appear multiply times as can the strUserName "markss". The same applies to the strScannedBatchNo and dtmScannedBatchDate.
So what I need to do is to count up the number of records in the tblTextFilesImported table for each UserName by Batch No and date, so I should get a record in each case something like this:
strUserName strScannedBatchNo dtmScannedBatchDate lngTotal
forda 00000167 17/11/2008 45
markss 00000167 17/11/2008 51
skidmoa 00000168 17/11/2008 78
etc
etc
I have written the following code:
==============
BEGIN CODE
==============
Dim rst As DAO.Recordset
Dim DB As Database
Set DB = CurrentDb 'Set DB to Equal the CurrentDB [current database]
'Count up the total records for each individaul and assign the value to the
'appropriate fields in the tblIndividualStats table
Set rst = DB.OpenRecordset("tblIndividualStats")
rst.AddNew
rst!dtmDateIndStats = Me![dtmScannedBatchDate]
rst!strUserNameIndStats = Me![strUserName]
rst!strScannedBatchNoIndStats = Me![strScannedBatchNo]
rst!lngTotalProcessed = DCount("[strScannedBatchNo]", "tblTextFilesImported", "[strUserNameIndStats] = Me![strUserName] And [strScannedBatchNoIndStats] = Me![strScannedBatchNo]")
rst.Update
rst.Close 'Close the Recordset
============
END CODE
============
This does'nt work, so I've clearly got it wrong. Any assistance would be much appreciated.
John Lee
I'm hoping someone may be able to assist me here. I have two tables, one which has data imported into it and the other that will store statistics based on the information in the imported data. My tables are named as follows:
tblTextFilesImported
tblIndividualStats
In the tbleTextFiles Imported I have three fields that I want to target as follows:
dtmScannedBatchDate
strUserName
strScannedBatchNo
I want to calculate the number of records per strUserName per strScannedBatchNo and the dtmScannedBatchDate.
All of the fields above can have variable data in them, that is to say for instance the strUserName "forda" can appear multiply times as can the strUserName "markss". The same applies to the strScannedBatchNo and dtmScannedBatchDate.
So what I need to do is to count up the number of records in the tblTextFilesImported table for each UserName by Batch No and date, so I should get a record in each case something like this:
strUserName strScannedBatchNo dtmScannedBatchDate lngTotal
forda 00000167 17/11/2008 45
markss 00000167 17/11/2008 51
skidmoa 00000168 17/11/2008 78
etc
etc
I have written the following code:
==============
BEGIN CODE
==============
Dim rst As DAO.Recordset
Dim DB As Database
Set DB = CurrentDb 'Set DB to Equal the CurrentDB [current database]
'Count up the total records for each individaul and assign the value to the
'appropriate fields in the tblIndividualStats table
Set rst = DB.OpenRecordset("tblIndividualStats")
rst.AddNew
rst!dtmDateIndStats = Me![dtmScannedBatchDate]
rst!strUserNameIndStats = Me![strUserName]
rst!strScannedBatchNoIndStats = Me![strScannedBatchNo]
rst!lngTotalProcessed = DCount("[strScannedBatchNo]", "tblTextFilesImported", "[strUserNameIndStats] = Me![strUserName] And [strScannedBatchNoIndStats] = Me![strScannedBatchNo]")
rst.Update
rst.Close 'Close the Recordset
============
END CODE
============
This does'nt work, so I've clearly got it wrong. Any assistance would be much appreciated.
John Lee
Last edited: