Link to home
Create AccountLog in
Avatar of sfn149
sfn149Flag for United States of America

asked on

Need a way to cancel changes if Error in Access DB

I use the below code to change values in a access database which has linked tables to a SQL DB.
Most of the entries in the DB will change with no problem but some will have to be changed manually because of some other issues.
What I need is a way to modify the code attached so that if the DB throws an error like the image that I have attached, the code will cancel any changes to the record and move on to the next record.       User generated image
RecNum = DCount("*", "LECaseSubjectQ")
MsgBox (RecNum)

    DoCmd.GoToRecord , , acFirst
Crec = 1

Do Until Crec > RecNum

strSubjectType = Form_LECaseSubjectQ.txtSubjectType.Text

If strSubjectType = "-18309" Then
    strSubjectType = "804"
End If

Form_LECaseSubjectQ.txtSubjectType.Text = strSubjectType

strSubjectType = ""

DoCmd.GoToRecord , , acNext
Crec = Crec + 1


Open in new window

Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of sfn149


that pointed me in the right direction, thanks