Can anyone help me out try to debug this code? I have a SubFunction that tracks changes made in some data entry forms by recording what was changed, the user that made the change, dates, etc. It all worked fine in the ".mdb" version of my database but when I converted to the new ".aacdb" version (Access 2007) I am running into an error message around the bolded/red line below. My gut says that something with the 'strSQL' defining statement no longer works right with Access 2007. FYI, the table that gets the data tracking information inputted to it is named "Audit", and the control fields in that table are all that come after the "rs!" statements. Any ideas as to how to fix this? The error I get is "Run Time error 13" and the description is "Type Mismatch". Thanks!
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim db As Database
Dim rs As Recordset
Dim strSQL As String
Dim strCtl As String
'Dim strReason As String
'strReason = InputBox("Reason For Changes")
strCtl = Me.ActiveControl.Name
strSQL = "SELECT Audit.* FROM Audit;"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
If rs.RecordCount > 0 Then rs.MoveLast
With rs
.AddNew
rs!FormName = Me.Name
rs!EncKey = [Enc Key]
rs!ControlName = strCtl
rs!DateChanged = Date
rs!TimeChanged = Time()
rs!PriorInfo = Me.ActiveControl.OldValue
rs!NewInfo = Me.ActiveControl.Value
rs!CurrentUser = fOSUserName
rs!Reason = strReason
.Update
End With
Set db = Nothing
Set rs = Nothing
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim db As Database
Dim rs As Recordset
Dim strSQL As String
Dim strCtl As String
'Dim strReason As String
'strReason = InputBox("Reason For Changes")
strCtl = Me.ActiveControl.Name
strSQL = "SELECT Audit.* FROM Audit;"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
If rs.RecordCount > 0 Then rs.MoveLast
With rs
.AddNew
rs!FormName = Me.Name
rs!EncKey = [Enc Key]
rs!ControlName = strCtl
rs!DateChanged = Date
rs!TimeChanged = Time()
rs!PriorInfo = Me.ActiveControl.OldValue
rs!NewInfo = Me.ActiveControl.Value
rs!CurrentUser = fOSUserName
rs!Reason = strReason
.Update
End With
Set db = Nothing
Set rs = Nothing
End Sub
Last edited: