Ok, I have tried to figure this out with no luck. I either get Runtime Error 2105 or 13.
I have a bound textbox "ReviewedBy" on a from with a query "InitialPrescriberReview" recordsource, I am trying to on AfterUpdate (ReviewedBy) ask a question as to whether to save changes or not.
If yes, requery the record set and go to the next record.
If no, remove what was entered into "ReviewedBy" and stay on the same record to make changes.
My code works unless I select "No" and then update the form enter the reviewedBy and it errors on the acnext.
Here is my code (I left some of the things I have tried as comments.)
Private Sub ReviewedBy_AfterUpdate()
Dim Msg, Style, Title
Msg = "Are you sure you have finished the review of this prescriber?" & vbNewLine & vbNewLine & " Yes, will remove this prescriber from the form" & vbNewLine & " No, will let you update additional information for the prescriber."
Style = vbYesNo + vbCritical + vbDefaultButton1
Title = "Critical"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then 'User chose Yes.
MyString = "Yes"
Me.cmdnxt.SetFocus
Me.ReviewedBy.Enabled = False
Me.Form.Requery
Me.Form.SetFocus
DoCmd.GoToRecord , , acNext
DoCmd.GoToControl "iC"
'DoCmd.GoToRecord "InitialPrescriberReview", , acNext
'Me.Form.SetFocus
Me.Requery
'DoCmd.GoToRecord acActiveDataObject, , acNext
Else 'User chose No.
'Me.Refresh
Me.Undo
Me.ReviewedBy = Null
Me.Form.SetFocus
Me.Requery
'Me.iC.SetFocus
'DoCmd.GoToRecord acActiveDataObject, , acNext
'DoCmd.GoToRecord acActiveDataObject, , acPrevious
End If
End Sub