K
Kelvin Beaton
I have this code (see below) in a form that is to write an audit record.
I have sample database that this code runs just fine in, but when I import
the same form and table into one of my production databases, I get an error.
"Run-time error '3265': Item not found in this collection."
When is stops it stops on " rs!UserName = CurrentUser"
I'm not a code writer so have little skill in trouble shooting this problem.
Any help would be appreciated
Kelvin
++++++++++++++++++++
Sub WriteAuditUpdate(txtTableName, lngRecordNum, txtFieldName, OrgValue,
CurValue)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tbl_AuditTable")
rs.AddNew
rs!tableName = txtTableName
rs!RecordPrimaryKey = lngRecordNum
rs!FieldName = txtFieldName
rs!LoginName = GetCurrentUserName
rs!MachineName = GetComputerName
rs!UserName = CurrentUser (it stops here)
rs!OriginalValue = OrgValue
rs!NewValue = CurValue
rs!DateTimeStamp = Now()
rs.Update
rs.Close
db.Close
End Sub
+++++++++++++++++++
I have sample database that this code runs just fine in, but when I import
the same form and table into one of my production databases, I get an error.
"Run-time error '3265': Item not found in this collection."
When is stops it stops on " rs!UserName = CurrentUser"
I'm not a code writer so have little skill in trouble shooting this problem.
Any help would be appreciated
Kelvin
++++++++++++++++++++
Sub WriteAuditUpdate(txtTableName, lngRecordNum, txtFieldName, OrgValue,
CurValue)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tbl_AuditTable")
rs.AddNew
rs!tableName = txtTableName
rs!RecordPrimaryKey = lngRecordNum
rs!FieldName = txtFieldName
rs!LoginName = GetCurrentUserName
rs!MachineName = GetComputerName
rs!UserName = CurrentUser (it stops here)
rs!OriginalValue = OrgValue
rs!NewValue = CurValue
rs!DateTimeStamp = Now()
rs.Update
rs.Close
db.Close
End Sub
+++++++++++++++++++