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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

turn off a warning 1

Status
Not open for further replies.

mrsbean

Technical User
Jul 14, 2004
203
US
I am using code to validate a text box with a result that is similar to a NotOnList event for a combo box.

Code:
If InvWidth Then
Me![Width].SetFocus

Cancel = True

Me![Width].Undo

End If

When an invalid width (or some other invalid value in another box) has been entered, I don't want the record to be updated. I get a message that says "2501 The RunCommand action was canceled." How can I turn off this message?

MrsBean
 
It is possible to use an error trap, for example:
Code:
If Err.Number = 2501 Then
   Exit Function
   'Or what ever you wish to do
Else
   MsgBox Err.Number & vbCRLF & Err.Description
End If

It may be possible to deal with the problem earlier, depending on what you are cancelling.
 
I have also seen

Warnings On
Specifies whether system messages are displayed. Click Yes (to turn on system messages) or No (not to turn off system messages) in the Warnings On box in the Action Arguments section of the Macro window. The default is No.

Remarks
For more information on how the action and its argument work, see the action topic.

If you turn the display of system messages off in Visual Basic, you must turn it back on, or it will remain off, even if the user presses CTRL+BREAK or Visual Basic encounters a breakpoint. You may want to create a macro that turns the display of system messages on and then assign that macro to a key combination or a custom menu command. You could then use the key combination or menu command to turn the display of system messages on if it has been turned off in Visual Basic.

Example
The following example turns the display of system messages off:

DoCmd.SetWarnings False

Joe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top