I have an Access application which has a table (AuditTrail) linked to SQL Server 2008. I am trying to add records to the audit trail table programmatically.
I have the f
With your current code, you are opening the entire table for no reason.
There are a couple of options.
One is to add a where clause that will return no records. Something like
Select dtDateTime, txtComment FROM AuditTrail WHERE <yourIdField> = -1
.
The second (my preference) would be to not use a recordset at all. Use an insert statement.
Dim strSql as String strSql = "INSERT INTO AuditTrail (dtDateTime, txtComment) Values(#" & Noe() & "#,'" & nz(MyComment,'') & "')"
Db.Execute strSql, dbFailOnerror + DbSeeChanges`