Hi Kevin
The biggest problem with your code is in your error handler...
ErrHandle:
Resume ErrExit
Resume ErrExit
If any error occurs, your procedure will just silently exit and you will have no indication that anything has gone wrong, much less what the error was, or where it occurred.
At the very least, you should have your error handler display a message:
ErrHandle:
MsgBox Err.Description
Resume ErrExit
Resume ErrExit
Also, instead of declaring a different string variable for every SQL statement, I would reuse the same variable, and include that in your error message so that you can see exactly which SQL statement is failing, and why:
Dim strSQL As String
strSQL = "DELETE * FROM tblGroupRoom" & _
" WHERE GroupID = " & Me.GroupID
db.Execute strSQL, dbFailOnError
strSQL = "DELETE * FROM tblGroupRoom" & _
" WHERE GroupID = " & Me.GroupID
db.Execute strSQL, dbFailOnError
strSQL = "DELETE * FROM tblPart" & _
" WHERE GroupID = " & Me.GroupID
db.Execute strSQL, dbFailOnError
" WHERE GroupID = " & Me.GroupID
db.Execute strSQL, dbFailOnError
strSQL = "DELETE * FROM tblPartBooking" & _
" WHERE PBGroupID = " & Me.GroupID
db.Execute strSQL, dbFailOnError
... etc - then in your error handler:
ErrHandle:
MsgBox Err.Description & vbCrLf & strSQL
Resume ErrExit
Resume ErrExit
Best wishes,
Graham [Access MVP 1996-2016]
__._,_.___
Posted by: graham@mandeno.com
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (7) |
Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.
SPONSORED LINKS
.
__,_._,___
Tidak ada komentar:
Posting Komentar