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

Would like to customize particular error messages

Status
Not open for further replies.

DanEaton

Technical User
Jun 24, 2002
60
CA
My database has a main data entry form called frmCatalogDataEntry. On that form are many different command buttons. Two such command buttons are to update info if it is not already in the combo boxes. For example, the user enters the catalogs date, and catalog#, only to find out that the supplier isn't in the combo box for suppliers. I have an "Add New" button beside the combo box that lets them jump to the frmSupplierDataEntry (via a macro that first closes the form). Once this occurs the program displays a 'The field SupplierID can't contain a Null b/c of requ'd property true' msgbox, then a 'you can't save the record at this time' one. If you hit 'ok', of course everything works. But the users will be confused at what's going on and what's being asked. I would prefer if there was a way to update the supplier, then just return without ever closing the frmCatalogDataEntry, but I get the same error messages when I try to add a refresh method into the macro or code. Is there a way around this so that the combo box will be refreshed without getting these error messages...Another compromise that I would settle for, would just to be able to customize (or annihilate) these error messages when the macro closes the frmCatalogDataEntry and opens frmSupplierDataEntry...Thanks Dan Eaton
deaton@caemachinery.com
 
Hi i had the same problem a few days a go and it was sorted out by the good people who use these forums. Take a look at this thread it should answer your question. It did mine.

thread702-324229
 
What you are asking for is error handling which is done in VBA code. Macros don't allow you to perform error handling. I suggest you consider converting your macros to VBA code and adding error handing to do whatever you wish when you receive an error. All you need to know is the error number that you get when you recieve and error and you can add it to the Select Case to handle it however you want. If you do handle the error then you probably would place a 'Resume Next' after it is handled to start processing immediately following the error line.

Public Sub ErrorHandlingSample()

On Error GoTo HandleErr

...

Exit_Proc:
Exit Sub

HandleErr:
Select Case Err.Number
Case 9 ' Subscript out of bound
MsgBox "You subscript in invalid."
Resume Exit_Proc
Case Else
...
End Select
End Sub
----------------------
scking@arinc.com
Life is filled with lessons.
We are responsible for the
results of the quizzes.
-----------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top