bypass error message box

janed

Registered User.
Local time
Today, 21:59
Joined
Feb 6, 2002
Messages
60
i have a code that bypasses a microsoft error but now it shows a message box with the error number in it. is there any way to hide this box? my code is#


MsgBox DataErr 'Use this to detect which error number to block.
If DataErr = 2237 Then 'If gives some stupid error message number 2237
Response = acDataErrContinue 'Don't show it
Else 'If it is any other error
Response = acDataErrDisplay 'Show it
End If


i would be very grateful if someone could show me how to edit the code appropriately. thank you.
 
Please help me! i know that i am very close to solving this problem and it is all thanks to this website. you have all been very good and patient with me and i really appreciate it. i think that once i solve this i will have what i want so if any of you have an idea what to do please let me know. thanks again
 
This code is an example only from your previous thread from Accessable. The reason that you are getting the error message still is that the code is trapping error 2237 only but any other error will throw up a message box. Look at the error number you have displayed and replace 2237 with it.
Be warned though it is better practice to stop error messages from occuring rather than ignoring them with this code (There are some exceptions to this though)

ps Try to follow the same thread and not start new ones if the problem is still the same. If you are trying to 'bump it up' the list just post to the original thread. It is useful to have the full context and history of the problem when replying (Lecture Over
wink.gif
)
HTH
 
how do i find the error number to replace it with. when i press ok to enter a new value to the list a box pops up that says error 2237. i don't really know what to do from there. can you help?
 
and also how do i stop error messages rather than ignoring them like you said. sorry i am quite new to access and i just can't seem to get my head around these codes.
 
If you keep in the line

MsgBox DataErr 'Use this to detect which error number to block.
it will always show a msgbox.

Either comment it out or delete it. Its purpose is to help with your debugging. The code is filtering the error but you are telling Access to show it anyway!

HTH
 
ok i am no longer getting the error but when i press ok to add the value to the list nothing happens. the code i am using is:


Private Sub Department_NotInList(NewData As String, Response As Integer)
If MsgBox("Value is not in list. Add it?", vbOKCancel) = vbOK Then
Set rec = CurrentDb.OpenRecordset("Record Entry Table")
rec.AddNew
rec!Department = NewData
rec.Update
Set rec = Nothing
Response = acDataErrAdded
Else
Response = acDataErrContinue
Department.Undo
End If
End Sub

would you know anything about that?
 
Check that the entry has been added into the "Record Entry Table" after adding a new entry to the list. If so....good.
Then add

Me.Department.Requery to the end of the code to refresh the combo's values.

HTH
 
no it isn't working. when i press add the list just pops back up and i cant move on. the values are being added to the table though so its just the combo box. where abouts in the code would i add that line and would it be word for word what you typed?
 
no it isn't working. when i press add the list just pops back up and i cant move on. i dont really know what you mean about it being added to the table.
 
please try. i'm so stuck and i dont know what to do
 
can anyone help me to complete this problem. in case i haven't made myself clear. i am trying to add a value to a combo box if it is not on the list. i have used the code above and the value is being added to the table but not to the combo box. if i press add the list just pops back up and i can't move on unless i enter a value from the list. any ideas?

[This message has been edited by janed (edited 03-20-2002).]
 
What I mean about being added to the table. Your combobox values will likely be taken from a table. Try adding a new value to the list and then seeing if that new value is added to the source table. You say the code is not being added to the combobox. If you add a item, close the form and then re-open the form, is the new value available in the combo?
Try putting the Me.NameOfCombo.Requery just above the End Sub.
 
my combo box is part of a large table but there is not a table for the combo box. i used a value list and i entered the values in myself.
 
no its not in the form when i close it as it won't let me go onto the next field unless i select something from the list.
 
would it help if i emailed you my database?
 
That's why you cannot add to the list as the combobox is using a predefied list you have typed in. Create a new table just with the values you want displayed in your combobox. (Ideally create a table with ID and displaydata then link the ID to the parent table). Create a new combo with the wizard and ask it to look up these values.
Then in your code, Replace "Record Entry Table" with the name of the table with thee newly stored values. It should now add to this table and make the new data available.
If you are still stuck, I'll send you a demo.
 
fizzio you have been brilliant. i have tried what you said and i am now getting a runtime error in the code. could you send me that example or shall i send you my database?
 

Users who are viewing this thread

Back
Top Bottom