If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Suppress or alter error message
I would like to supress the error message which comes as err.number 0.
"You can't save this record at this time. [MyApp] may have encountered an error while tryign to save a record. If you close this object now, the data changes you made will be lost. Doyou want to close the database object anyway? This occurs when the user uses the X in the upper right of the form to close the application while it is in its validation routine. I want the user to be able to exit the form (they don't know the answer) without changing the current data - loosing the changes they made, BUT I want the message to be more descriptionve AND have the option to return to the form or close and loose the changes they made. I added the error handling routine as in the code below which knows the error is 0 and will display the message I have and I could add a yes/no to do the return to the form BUT the message I listed above 0 message still displays. Any suggestions? On Error GoTo HandleErrors DoCmd.SetWarnings False Dim blnContinue As Boolean Dim ctl As Control blnContinue = True For Each ctl In Me.Controls If ctl.Tag = "Required" Then If IsNull(ctl) Then MsgBox "You must fill in the " _ & ctl.ControlSource & " field." Cancel = True ctl.SetFocus Exit For End If End If Next ctl Set ctl = Nothing ExitHe DoCmd.SetWarnings True Exit Sub HandleErrors: 'MsgBox Err.Number Select Case Err.Number Case 0 ' You can't save this record at this time. Close database object Yes/No MsgBox "You did not complete a required field. Your data changes will NOT BE SAVED." Case Else 'Call a generic error handler Call GenericHandler End Select Resume ExitHere End Sub |
#2
|
|||
|
|||
Suppress or alter error message
You can put the code on the BeforeUpdate event so that the record can be
cancelled or undone if validation does not pass... '~~~~~~~~~~~~~~~~~~~~~~~~~~ Cancel = true if MsgBox("Validation failed. YES to fill in rest of record, NO to lose edits", vbYesNo,"Keep editing or Cancel") = vbNo then me.undo end if '~~~~~~~~~~~~~~~~~~~~~~~~~~ "uses the X" -- this will trigger the form UnLoad event ... Warm Regards, Crystal * (: have an awesome day * MVP Access Remote Programming and Training strive4peace2006 at yahoo.com * DWL wrote: I would like to supress the error message which comes as err.number 0. "You can't save this record at this time. [MyApp] may have encountered an error while tryign to save a record. If you close this object now, the data changes you made will be lost. Doyou want to close the database object anyway? This occurs when the user uses the X in the upper right of the form to close the application while it is in its validation routine. I want the user to be able to exit the form (they don't know the answer) without changing the current data - loosing the changes they made, BUT I want the message to be more descriptionve AND have the option to return to the form or close and loose the changes they made. I added the error handling routine as in the code below which knows the error is 0 and will display the message I have and I could add a yes/no to do the return to the form BUT the message I listed above 0 message still displays. Any suggestions? On Error GoTo HandleErrors DoCmd.SetWarnings False Dim blnContinue As Boolean Dim ctl As Control blnContinue = True For Each ctl In Me.Controls If ctl.Tag = "Required" Then If IsNull(ctl) Then MsgBox "You must fill in the " _ & ctl.ControlSource & " field." Cancel = True ctl.SetFocus Exit For End If End If Next ctl Set ctl = Nothing ExitHe DoCmd.SetWarnings True Exit Sub HandleErrors: 'MsgBox Err.Number Select Case Err.Number Case 0 ' You can't save this record at this time. Close database object Yes/No MsgBox "You did not complete a required field. Your data changes will NOT BE SAVED." Case Else 'Call a generic error handler Call GenericHandler End Select Resume ExitHere End Sub |
Thread Tools | |
Display Modes | |
|
|