If you are running a Total Access Statistics scenario and it encounters an error while trying to read your data, your table may contain corrupt data.
This is particularly true if the error log says it crashes here:
where FieldName is the name of your field with the invalid data.
While we trap for many types of invalid and missing data, we are receiving reports of corrupt data that we have been unable to reproduce in our test environments. It may be related to linked tables to non-Access data sources.
To see if there's a problem reading data from a field in your table, insert this VBA function into a module in your database and run it:
Public Function TAS_TestFieldValues(ByVal strTable As String, ByVal strField As String) As Boolean ' Comments: Procedure invoked by user to test if all values from a table's field can be read. ' Params : strTable Table name ' strField Field name ' Return : True if successful, False if not ' Created : FMS, Inc. Dim fOK As Boolean Dim dbs As DAO.Database Dim rst As DAO.Recordset Dim varTest As Variant fOK = False Set dbs = CurrentDb Set rst = dbs.OpenRecordset(strTable, dbReadOnly, dbSeeChanges) With rst
Do While Not .EOF
' Crashes here if the value can't be read varTest = rst.Fields(strField) .MoveNext
Loop End With fOK = True rst.Close dbs.Close Set dbs = Nothing TAS_TestFieldValues = fOK End Function
You can call the function from the Immediate Window, and pass the name of your table and field for the parameters:
? TAS_TestFieldValues("TableName", "FieldName")
It attempts to read every value of a field in all the records of your table. It will crash on the record if the field can't be read.
Note that this code uses DAO and works within a Jet database (ACCDB or MDB) and not an ADP database file type.