Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i cancel beforeupdate msgbox 1

Status
Not open for further replies.

joshkay

Technical User
Jun 14, 2001
10
0
0
AU
i have a record validation performed on the before-update procedure.If the record isn't valid and i cancel it i need to omit the default msgbox and add my own so i can grab values ie cancel,ok i am using access97
anyhelp would be appreciated
s-)
 
I hope this makes enough sense. What you want to do is set the Cancel parameter to True.

Private Sub Form_BeforeUpdate(Cancel As Integer)
'Put Code To Check Validity Here
MsgBox "Update Canceled"
Cancel = True
End Sub
 
what i have done is used code for form_unload.I have cancelled the close but i then get a msgbox"You cant save this record at this time".I am tryingto get rid of this msgbox somehow
might be fighting a losing battle
 
Sounds like you have a key or index violation. Try adding this bit of code into what you have. It'll wipe out all active TextBoxes and ComboBoxes.

Sub DeleteControls()

Dim conControl As Control

For Each conControl In Me.Controls
If conControl.Properties("ControlType") = acTextBox Or conControl.Properties("ControlType") = acComboBox Then
conControl = ""
End If
Next conControl

End Sub
 
Thanks pezamystik,That works like a charm. Its amazing what you can achieve when you ask!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top