On error displayes default error code instead of the specifyed one

Hi,

I have added error handling code to my combo box.

Private Sub searchName_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object
    On Error GoTo ERR_Handler

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[sdutentId] = " & Str(Nz(Me![searchName], 0))
On Error GoTo 0
Exit Sub
ERR_Handler:
  MsgBox "Please empty search box before continuing!"
End Sub



But it doesn't display the message in msgbox, it displayed default ms access 
error code. which is "The text you have entered isn't an item in the list."

Any idea why would it do it?
0
Utf
12/23/2009 12:54:01 AM
access.modulesdaovba 1670 articles. 0 followers. Follow

6 Replies
752 Views

Similar Articles

[PageSpeed] 8

If the item is not in the list, the combo's NotInList event fires. The 
combo's value doesn't get updated, and so its AfterUpdate event never runs.

Use its NotInList event. Here's some more examples of adding a value to the 
lookup table:
    http://allenbrowne.com/ser-27.html

-- 
Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"lord" <lord@discussions.microsoft.com> wrote in message 
news:34847807-23FC-4730-82F4-4FC4ACF918A9@microsoft.com...
> Hi,
>
> I have added error handling code to my combo box.
>
> Private Sub searchName_AfterUpdate()
>    ' Find the record that matches the control.
>    Dim rs As Object
>    On Error GoTo ERR_Handler
>
>    Set rs = Me.Recordset.Clone
>    rs.FindFirst "[sdutentId] = " & Str(Nz(Me![searchName], 0))
> On Error GoTo 0
> Exit Sub
> ERR_Handler:
>  MsgBox "Please empty search box before continuing!"
> End Sub
>
>
>
> But it doesn't display the message in msgbox, it displayed default ms 
> access
> error code. which is "The text you have entered isn't an item in the 
> list."
>
> Any idea why would it do it? 

0
Allen
12/23/2009 2:15:37 AM
Thanks for reply,

the link that you have sent me is good for when the item is not in the list.

On my form, I need to add bunch of error messages for various cases, 
starting from date format, to phone numbers format. So I wonder is there a 
generic way to popup a message with an error, so that the user would know 
what to do.

Thank you!
0
Utf
12/23/2009 5:08:02 AM
Use the form's Error event to trap engine-level errors, e.g. wrong data 
type, required field missing, unique index violation, referential integrity 
violation.

-- 
Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"lord" <lord@discussions.microsoft.com> wrote in message 
news:EED9048A-974A-47C8-8042-A99A077592B7@microsoft.com...
> Thanks for reply,
>
> the link that you have sent me is good for when the item is not in the 
> list.
>
> On my form, I need to add bunch of error messages for various cases,
> starting from date format, to phone numbers format. So I wonder is there a
> generic way to popup a message with an error, so that the user would know
> what to do.
>
> Thank you! 

0
Allen
12/23/2009 8:06:41 AM
Would you be able to give an example on how to use those, and is there any 
way to find out which error event was launched during an error.

Thank you!
0
Utf
12/23/2009 4:33:01 PM
"lord" <lord@discussions.microsoft.com> wrote in message 
news:0BB3586B-6C16-4DA0-9D4E-253E9B0BB24E@microsoft.com...
> Would you be able to give an example on how to use those, and is there
> any way to find out which error event was launched during an error.

If it is the user (not code) that's doing the entry, you could examine 
Form.ActiveControl to see which control has the focus.

I didn't follow the bit about the event that caused the error, as it's not 
really event related but engine-related.

Here's an example of a generic function you could put into an standard 
module, and then call it in the Error event of any form with:
        Call FormError(Me, DataErr, Response)

Function FormError(frm As Form, DataErr As Integer, Response As Integer) As 
Integer
On Error GoTo Err_FormError
    'Purpose:   Generic Form_Error handler.
    'Return:    Response.
    'Usage:     In a form's Error event procedure:
    '               Call FormError(Me, DataErr, Response)
    Dim strMsg As String
    Const conDupeIndex As Integer = 3022
    Const conFileMissing As Integer = 3024
    Const conRelatedRecordRequired As Integer = 3201
    Const conWrongDataType As Integer = 2113

    Select Case DataErr
    Case conDupeIndex
        strMsg = "The record cannot be saved, as it would create a 
duplicate."
        Response = acDataErrContinue

    Case conRelatedRecordRequired
        Response = acDataErrDisplay

    Case conFileMissing
        strMsg = "Data file is currently unavailable."
        Response = acDataErrDisplay

    Case conWrongDataType
        strMsg = "The data type is not suitable."

    Case Else
        Response = acDataErrDisplay
    End Select

    If Len(strMsg) > 0 Then
        MsgBox strMsg, vbExclamation, "CUSTOM TITLE"
    End If
    FormError = Response

Exit_FormError:
    Exit Function

Err_FormError:
    Call LogError(Err.Number, Err.Description, "FormError()", "DataErr: " & 
DataErr)
    Resume Exit_FormError
End Function

-- 
Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
 

0
Allen
12/24/2009 3:01:49 AM
Thank you, I will examine the code and see how I can implement it. :)
0
Utf
12/26/2009 2:44:01 AM
Reply:

Similar Artilces:

Excel Progrom Error
Hi there Happy new year to all. I often receive the folowing error message in a box titled "Program Error". EXCEL.exe has generated errors and will be closed by Windows. You will need to restart the program. An error log is being created. The only option is OK which closes Excel. I do not know where the error log is created. I am using Office 2000 Service Pack 3 with Windows 2000 Professsional Service Pack 4. Can anybody throw some light on this error. Thanks in anticipation. Michael What are you doing at the time (i.e. is it consistent)? -- Regards; Rob ----------------...

Value in a cell is sum of one or more other cells
Hi all, I have a column of cells containing positive and negative values. I want to find those cells which equal the sum of 2 or more other cells. I have no VBA experience. Many thanks, Colin -- karabiners ------------------------------------------------------------------------ karabiners's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=25584 View this thread: http://www.excelforum.com/showthread.php?threadid=390062 ...

Sharebuilder account import error
Invalid .qif header error when trying to import .qif file from sharebuilder accounts. Anyone know of a fix or experienced this problem?? I typed a long mail to sharebuilder regarding this issue...still waiting fora reply. Hopefully they will be able to help. Microsoft flat out told me it wasn't their issue and to contact my broker! No help AT ALL. Microshaft..... OMalley ...

Messages saved to Deleted Items instead of Drafts
I am using Outlook 2003 SP2 (Office 2003 Pro) in Windows XP Pro SP2, with all available patches to Windows and Office. If I start a message or a Reply and click the Save icon, the saved message is "saved" to the Deleted Items folder instead of the Drafts folder. If I close the message (as one would do if one were planning to continue later) and empty the Deleted Items folder the message is lost. If I go to Tools, Options, Preferences, E-mail Options..., Advanced E-mail Options..., "Save unsent items in:" has "Drafts" selected, so it should save them in the...

2003 Keeps the default workbook open
When I start Excel, it starts up with a blank workbook. If I immediately open a saved file, it closes the blank workbook... All good... except mine has stopped closing the blank one. So I always end up with 2 workbooks open, the one I opened and a blank one that I'm not interested in! Is this a setting? if so where? Can I fix it? thanks... M Did you or someone create a default workbook (ie, Book.xltx or Book.xltm) and save it in "C:\Users\YourUsername\AppData\Roaming\Microsoft\Excel\XLSTART"? On 5/9/2010 4:17 AM, Michelle wrote: > When I start...

DPM2010 RC Errors on secondary server.
We have recently upraded our 2007 SP1 Primary DPM server to 2010 RC and it is working perfectly. I've set up a brand new, fresh Windows 2008 R2 Server for the secondary server, and have told it to protect one of the protection groups on the primary server. Everything works for a little while, but every half hour or so, the DPM service crashes and says: "Connection to the DPM service has been lost. Review the application event log for information about a possible service shutdown. ID: 917" Then asks to restart the administrator console. This kills the ...

ERROR
Hi I am using a spreadsheet in Excel 2002 on Windows XP, for some reason the account numbers (which someone input, along with addresses) have a little green mark in the corner of the cell. I thought it was to show that there is a comment, but it is not. When you click on the cell, a little warning sign shows, saying ERROR - number in this cell formatted as text or preceded by an apostrophe. When I click on the arrow by the warning sign, it says Number stored as text Convert to number Ignore error Edit in formula bar Error checking options Show formula in audinting toolbar Now I looked a...

How to carry over date value from one record to the next.
I have searched this site and the internet in search of an answer to this problem but none of the solutions I've found have seemed to help. I have a form that is used for data entry. The first two text boxes are called Supervisor and W/E Date. These two values will remain the same for several dozen entries. I have tried just using CTRL + ' to repeat the data but that is getting quite time consuming as well. How do I automatically carry over the value to the next record once I input the first data in? Any help on this would be much appreciated. -- Message posted via AccessMo...

error, chkdsk
Questio, when I try to open excel or winmx, an error pops up saying chkdsk, so i ran a chkdsk and it doesnt do anything. The error also says corrupted file. In excel I have some important work that I need to open, and it only opens in Turkish, if I change it to English, its a bunch of boxes and letters, its not my work I need. How do I change it back. What excel version are you using? Try to find somebody with 2003 to see if they can open the file. Otherwise you would look for some commercial software that might be of help http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B30...

4.4.7 error
I have problems on one client that they don't recieve all emails from people sending to them. I guess something is wrong in the configuration. When I do a nslookup -type=mx domain.com I just get unautharized answer. Also the ttl time is just 1800 when I do a dns report. Do the guys that handle the dns change this? The people that doesn't get their mail throw get the 4.4.7 error in return. Best regards Jimmy http://support.microsoft.com/kb/555375 -- Ed Crowley MVP "There are seldom good technological solutions to behavioral problems." .. "Surfer&q...

error 0x800CCC0F
Dear Team; I am receiving the following error messages, please assist Could result be sent to lewis.king@riotinto.com regards Lew Your server has unexpectedly terminated the connection. Possible causes for this include server problems, network problems, or a long period of inactivity. Subject 'brocolli & mushroom stir fry noodle', Account: 'pop.gmail.com', Server: 'smtp.gmail.com', Protocol: SMTP, Port: 995, Secure(SSL): Yes, Error Number: 0x800CCC0F Your server has unexpectedly terminated the connection. Possible causes for this include server p...

delete server...routing master error
hello, I have 2 exchange servers (exch 2003) and i have to delete one of them. I changed all replication etc...(before we had also a 5.5 which is already removed) but when i stop the services and try to remove the server via system manager of my second exchange (the one that will stay) i get an error message that my server that i want to delete is the routing master for that group. How can i make my other server the routing master ? i don't have any site replication (deleted it because not necessary anymore). thnx, Philippe Go to routing groups > first routing group > mem...

Excel error codes translations
hi, Does anybody know where I can find a kind of dictionary for Exce errors? The problem is sometimes I get an error message that is not in Englis and without error code and then looking for the solution I must kno its equivalent in English. Regards, Micha -- Message posted from http://www.ExcelForum.com ...

toolbar, date, services, errors, paste, minimized system restore doesn't work
I have a XP system that the toolbar does not show open programs, services do not seem to load at boot, the date is off by one month, I cannot paste anything that I copy, and system restore does not work. All of these issues started at the same time a few days ago. Has anyone else seen this group of errors? I am trying to resolve and do not know if it is a system update gone bad, or if maybe it is a viruse/malware issue. Please let me know if you had had these problems together and what you did to fix them. There is a very good chance that you are seeing the effects of a hi...

Can you link many workbooks to one template? And Update?
I tack around 100 different workbooks. All are the same "template"; however, I often update the formulas and therefore must go back to each workbook and update them formulas. Is there a way to link all of the workbooks to a "template" to calculate the formulas? And can I change the one template formula so all the workbooks are updated at once? ...

Re: Money 2004
Thanks for the suggestion. I tried unregistering/re-registering the msxml3 DLL, but still no luck. However, knowing the help file topics are local might help with debugging this problem. thanks, randy "Randy" <nospam@hotmail.com> wrote in message news:... > All, > > I've recently upgraded to Money 2004 Premium from 2003 Deluxe. I'm now > finding that I can't view any help topics--I get the "Unable to load topic. > Click here to try again." I've tried all the suggestions posted here and at > other sites: cleared out temporary in...

Default File Renaming
When I save my files as webpages Publisher automatically renames alllllll of my files to Img001 Img002 etc etc and I have to go through the HTML and change ALL the file names so that it pulls the right pictures... my site is huge, this is tedious and annoying... can anyone help??? It is not renaming your image files, it is making copies of them. If you are renaming those copies than your page won't load the images because the file names will be wrong. I recommend you visit my site and review the articles I have for the version you are using. If you require anything further please use ...

set up different default printer for MS Excel
I have a printer A set up as default for my PC. I want to have a printer B to be default one for ALL NEW Excel files. So task is not to change it manually or via some macro button; the task is to have the printer B ready directly after opening of Excel file. Any suggestions? Stefan, You can change the default printer for all applications with the Windows Control Panel. Start - Control Panel - Printers and Faxes. Right-click the printer you wish to be the default, and choose "Set as Default." To set a default printer for Excel only (different from the Windows default printer...

"File Error: Data May Be Lost" error when opening workbook saved in Mac
When I open in Excel 2007 for Windows workbook with charts saved in Mac OS, I see the message "File Error: Data May Be Lost". In Excel 2003 for Windows this message appears as many times as many sheets there are in workbook. Maybe someone knows what's the reason? Unfortunately you haven't provided the info needed... "Mac OS" means very little. The question is "What version of Mac Excel are you using, what file format are the files saved as & what type of content is in the files?" In general, what you're running into is that Excel 2003 &a...

Technical error
AMEX and Discover are not being sent over to the credit card processor during settlement. I comes up with a "TECHNICAL ERROR". Visa and MC are settling fine. Does anyone know what the problem is?? All are setup as different tranaction types in RMS and ALL authorize fine during the transaction process. Your merchant account is not correctly configured for AMEX & Discover. This is on the bank's side, not RMS. -- Glenn Adams Tiber Creek Consulting http://www.tibercreek.com glenn@tibercreek.com ---------------------------------------------- Please DO NOT respond to me dir...

Iterating the combo box and displaying the value after each change on seprate sheet.
Here i have a combo box form control, from where i will be picking the value and displaying it on other sheet. Now i am updating the sheet with combo box control, value is getting pasted on Consolidated-Report using: Worksheets("Consolidated-Report").Range("a9").Value = Me.ComboBox2.Value If now i again go back to combobox sheet and change the value, same cell is getting updated. I need to move to next row for each time the value is updated in combo box and paste the same on Consolidated-Report sheet. Note: A Combobox from the Control Toolbox has the name ComboBoxN; ...

CObject Private method access error
Hi, I am trying to recompile application that has been developed in VC++ 6.0 with VC++2005.. While compiling, I'm getting the following error.. error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject' 1> c:\program files\microsoft visual studio 8\vc\atlmfc\include\afx.h(553) : see declaration of 'CObject::CObject' 1> c:\program files\microsoft visual studio 8\vc\atlmfc\include\afx.h(524) : see declaration of 'CObject' 1> This diagnostic occurred in the compiler generated function 'CExcepti...

Email Just One Sheet
Is there a way to email just one sheet of many in a workbook as a attachment. I have supervisors in the field that have field tickects they keep in one work book. They email them over a satelite connection, so I would like to just send the ticket for that day. Thanks, Chance Hi Chance Ron de Bruin is the expert on this. Tons of code at his page http://www.rondebruin.nl/sendmail.htm and at the very end a free downloadable add-in that does this and more for you. -- HTH. Best wishes Harald Excel MVP Followup to newsgroup only please "Chance" <clagarde@tetratec.com> skrev ...

Error in closing Outlook
Application error ciceroUIWndFrame. The instruction at 0x7e430240 reference memory cannot be written 0x7e42631A Also unable to dial a phone using Outlook. Sanford Take a look here http://support.microsoft.com/kb/323613 -- Peter Please Reply to Newsgroup for the benefit of others Requests for assistance by email can not and will not be acknowledged. "Sanford Aranoff" <aranoff@analysis-knowledge.com> wrote in message news:4B6CD165.E7510293@analysis-knowledge.com... > Application error ciceroUIWndFrame. > The instruction at 0x7e430240 reference me...

Typing message error
I have an Asus Eee PC netbook which came with a Microsoft Works 2007 trial. I'm unable to type anything on a Word document. An error message flashes briefly at the bottom of the screen, "This modification is not allowed because the selection is locked." I'm baffled. Is this a computer problem or a Works problem and how can this be fixed? Thank you. I would be surprised if any system nowadays came with a Works trial; more likely it is an Office 2007 trial (and if it *is* Works, then you're in the wrong discussion group). If the computer is quite new, then...