By the way, here's the code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dim wrkCurrent As DAO.Workspace | |
Dim dbsNorthwind As DAO.Database | |
Dim rstEmployee As DAO.Recordset | |
On Error GoTo ErrorHandler | |
Set wrkCurrent = DBEngine.Workspaces(0) | |
Set dbsNorthwind = CurrentDB | |
Set rstEmployee = dbsNorthwind.OpenRecordset("Employees") | |
wrkCurrent.BeginTrans | |
Do Until rstEmployee.EOF | |
If rstEmployee!Title = "Sales Representative" Then | |
rstEmployee.Edit | |
rstEmloyee!Title = "Sales Associate" | |
rstEmployee.Update | |
End If | |
rstEmployee.MoveNext | |
Loop | |
If MsgBox("Save all changes?", vbQuestion + vbYesNo) = vbYes Then | |
wrkCurrent.CommitTrans | |
Else | |
wrkCurrent.Rollback | |
End If | |
rstEmployee.Close | |
dbsNorthwind.Close | |
wrkCurrent.Close | |
Set rstEmployee = nothing | |
Set dbsNorthwind = Nothing | |
Set wrkCurrent = Nothing | |
Exit Sub | |
ErrorHandler: | |
MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description |
Komentar