Before Update Event Property Code

C

Confused

For existing records-When a user changes a name on a combo box, how do I get
the DB to ask the question, "Are you sure you want to change this record"
And if they hit cancel, change the field back to it's original property?
 
W

Wayne-I-M

Dim intResponse As Integer
intResponse = MsgBox("Are you really sure you want to alter this
record?," & vbCrLf & vbCrLf & "This will update the record." & vbCrLf &
vbCrLf & "Click NO to Cancel" & vbCrLf & vbCrLf & "Click YES to continue",
vbYesNo, "Change record ?")
 
D

Douglas J. Steele

I think you need a little more than that, Wayne.

Private Sub NameOfComboBox_BeforeUpdate(Cancel As Integer)

If MsgBox("Are you really sure you want to alter this record?" & _
vbCrLf & vbCrLf & "This will update the record." & vbCrLf & _
vbCrLf & "Click NO to Cancel" & vbCrLf & vbCrLf & _
"Click YES to continue", vbYesNo, "Change record ?") = vbNo Then
Me.NameOfComboBox.Undo
Cancel = True
End If

End Sub
 
W

Wayne-I-M

Hi Douglas

yes you are right I forgot the last section - LoL what-do-I-know

maybe shouldn't write on this thing at half past 10 at night :)
 
C

Confused

Thank you immensely!

Douglas J. Steele said:
I think you need a little more than that, Wayne.

Private Sub NameOfComboBox_BeforeUpdate(Cancel As Integer)

If MsgBox("Are you really sure you want to alter this record?" & _
vbCrLf & vbCrLf & "This will update the record." & vbCrLf & _
vbCrLf & "Click NO to Cancel" & vbCrLf & vbCrLf & _
"Click YES to continue", vbYesNo, "Change record ?") = vbNo Then
Me.NameOfComboBox.Undo
Cancel = True
End If

End Sub
 
Top