B
Bob H
When I add a new record to a form, then save it before selecting another
record or using find to find another record, I get an error at these
lines, one after the other when I rem the first one out etc.
rs!PriorInfo = Screen.ActiveControl.OldValue
rs!NewInfo = Screen.ActiveControl.Value
rs!RecordID = Screen.ActiveForm.CurrentRecord
How can I get the code to accept a new record, let me save it then carry
out another operation without breaking down
Function TrackChanges()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim strCtl As String
'Dim strReason As String
'strReason = InputBox("Reason For Changes")
strCtl = Screen.ActiveControl.Name
strSQL = "SELECT tblAudit.* FROM tblAudit;"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
If rs.RecordCount > 0 Then rs.MoveLast
With rs
.AddNew
rs!FormName = Screen.ActiveForm.Name
rs!ControlName = strCtl
rs!DateChanged = Date
rs!TimeChanged = Time()
rs!PriorInfo = Screen.ActiveControl.OldValue
rs!NewInfo = Screen.ActiveControl.Value
rs!RecordID = Screen.ActiveForm.CurrentRecord
rs!CurrentUser = fOSUserName
'rs!Reason = strReason
.Update
End With
Set db = Nothing
Set rs = Nothing
End Function
record or using find to find another record, I get an error at these
lines, one after the other when I rem the first one out etc.
rs!PriorInfo = Screen.ActiveControl.OldValue
rs!NewInfo = Screen.ActiveControl.Value
rs!RecordID = Screen.ActiveForm.CurrentRecord
How can I get the code to accept a new record, let me save it then carry
out another operation without breaking down
Function TrackChanges()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim strCtl As String
'Dim strReason As String
'strReason = InputBox("Reason For Changes")
strCtl = Screen.ActiveControl.Name
strSQL = "SELECT tblAudit.* FROM tblAudit;"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
If rs.RecordCount > 0 Then rs.MoveLast
With rs
.AddNew
rs!FormName = Screen.ActiveForm.Name
rs!ControlName = strCtl
rs!DateChanged = Date
rs!TimeChanged = Time()
rs!PriorInfo = Screen.ActiveControl.OldValue
rs!NewInfo = Screen.ActiveControl.Value
rs!RecordID = Screen.ActiveForm.CurrentRecord
rs!CurrentUser = fOSUserName
'rs!Reason = strReason
.Update
End With
Set db = Nothing
Set rs = Nothing
End Function