Yes/No on Change

  • Thread starter Thread starter klr397
  • Start date Start date
K

klr397

I have a last field name that i need to have a msgbox come up and keep the
user from accidentily wipeing out the last name field. however i am
completly stuck on my code.

Private Sub LastName_Change()
Dim Answer As Integer
Answer = MsgBox("Do you wish to change this candidates Last Name?",
vbQuestion + vbYesNo, "Question")

If answer= VbYes Then

Else

End If

End Sub

Any one want to fill in my if statement it would be much apreciated
KAtie
 
The Change event fires with every keystroke. Use the control's BeforeUpdate
to question, or AfterUpdate to change it back to the old value if the user
does not agree to the change:

Private Sub LastName_AfterUpdate()
Dim strMsg As String
With Me.Lastname
If Not IsNull(.OldValue) Then
strMsg = "Change the name from " & .OldValue & _
" to " & Nz(.Value, "nothing") & "?"
If MsgBox(strMsg, vbYesNo+vbQuestion, "Confirm") <> vbYes Then
.Value = .OldValue
End If
End If
End With
End Sub
 
Back
Top