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
1158 Views

Similar Articles

[PageSpeed] 13

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:

Paragraph formating jumps to defaults.
Hi, We are using Office/Outlook 2007 We have an email signature script that is run when users login, it´s working ok except for two things; If the default paragraph settings in Word 2007 for a user matches those in the signature script, the signature will use the "Base defaults" of Word 2007, that is SpaceAfter = 10 and LineSpacing = "Multiple" with a value of 1,15. So if I change the script to use SpaceAfter=0 and the user has set his/her Word 2007 to use SpaceAfter=0, the result will be SpaceAfter=10. If the script is set to SpaceAfter=0 and the us...

TempVars unusable in field default value
Hello, I'm trying to use a temporary variable to keep track of which CSR is inputting data. I have a macro which prompts user for ID code, which is stored in the temp variable TempUser. On a form control default value property, I can use the expression [TempVars]![TempUser], which will populate that user's ID code into the control. However, I cannot use that same expression in the tables field default value property. If I try, when I save the changes to the table, I get the error message "Could not find the field 'TempVars]![TempUser'. " Any ideas why I ca...

Office 2003 on WinXP is receiving an error...
This operating is not presently configured to run this application.' This nmessage keeps popping up after I install WInXP Sp2. Right after I install office 2003, and I try to open MS word 2003, the above message appears. Can anyone point me in the right direction? RodneyJ Insert office cd>repair "RodneyJ" <u58446@uwe> wrote in message news:a43130535cd3e@uwe... > This operating is not presently configured to run this application.' This > nmessage keeps popping up after I install WInXP Sp2. Right after I > install > office 2003, and I t...

Too Many IF Statements Nesting Error (Excel Formula Loop w/o VBA)
Hello Excel Problem Gurus, First of all, let me thank you in advance. I find it exemplary that you all can devote time to helping others who are having issues with their work. Hopefully one day I can be at a mentor level, and help others too. Hope you can help! I have an issue where I don't know how to write the formula that I need without going over on the nesting. The current formula that I have is as follows: =IF(OR(B7="",J7="",L7="",M7="",N7="",O7="",P7=""),"No Data",IF(V7="Yes",&qu...

if cell is text move left one column
ColB is a long list with sections names followed by category codes I need to move the text into colA leaving colB with codes only (all numbers) ColB. Doors 940590 555998 447006 447008 810697 810705 810706 810707 Windows 619435 525691 525692 Try Sub Macro1() Dim lngRow As Long For lngRow = 1 To Cells(Rows.Count, "B").End(xlUp).Row If Not IsNumeric(Range("B" & lngRow)) Then Range("A" & lngRow).Value = Range("B" & lngRow).Text Range("B" & lngRow).Value = "" End If Next End Sub -- Jacob ...

Date display in Excel
Format column of cells as Date, display as mm/dd/yy. Date entered into cell, shows up correctly in the text entry field at the top of the screen, but the data on the worksheet displays as "33747", or similar number. Only happening on one workbook. Try tools|options|View tab|uncheck Formulas. Clark wrote: > > Format column of cells as Date, display as mm/dd/yy. Date > entered into cell, shows up correctly in the text entry > field at the top of the screen, but the data on the > worksheet displays as "33747", or similar number. Only > happening on one...

Errors saving to network drive
When my users open an Excel spreadsheet located on a network drive, make their changes, and then try to save the spreadsheet, they get an error message saying "Your changes could not be saved to Whateverfile.xls, but were saved to XXXXXXXX ( 8 digit hex number ). Close the existing document, then open the temporary document and save it under a new name" The users have been explicitly granted full rights, including Delete and Modify, to the shared folder in which the spreadsheet resides. I have disabled their Symantec Antivirus realtime protection for the time being. This pr...

send the same e-mail with one or two fields changed.......
I would like to send the same e-mail to many differnet people with one or two fields changed (for example the name of recipient and the date).How canthis be done?? I would also like to be able to save the e-mail and use it again and again. can anyone help cheers john If you have Word installed and it's the same version as Outlook (both 2003, for example), you can do a mail merge between the two. This would allow you to set up the text the way you want it to, and you can save the document for future use. Look at the following page for further information: http://www.slipstick.com/con...

Multiple domains on one Exchange server / All but one domain shows up as spam #2
I am sorry if this is on the board somewhere but I have been searching forever and havn't found a hint yet. I have multiple domains setup on my exchange server. Lets say abc.com, def.com, and hij.com. We only send email with @abc.com but can receive from any domain name. Recently we merged with another company and we brought back their email to our server, lets say xyz.com. Now I configured a new recipient on Exchange 2003, so I now have two policies. The first policy has the three original domains in it with @abc.com as the primary domain. In the second policy I have configured xyz.com t...

Displaying Scenarios
I have set up a number of scenarios on a worksheet as they relate to different versions of my budget. Rather than having to go in everytime and display each one individuall, I would like to enter a parameter in one cell that will automatically display the right scenarios. Hopefully, using a conditional statement of some kind. Any help would be greatly appreciated. Jeffrey Albaum Controller Jet Moulding Compounds Inc. Ajax, Ontario, Canada How about a worksheet_change event? I created a couple of custom views and then rightclicked on the worksheet tab that held the important cell. ...

Error loading XML into DataSet
Hello, When I try to load this xml file (see below) into an asp.net dataset using the following code: ds.ReadXml("xmlfilepath\xmlfile.xml", XmlReadMode.Auto) I get the following error: "The same table (description) cannot be the child table in two nested relations. " If I take out the anchor tag in the description it works fine, however, I need the anchor tag in there. Does anyone have any suggestions? <?xml version="1.0" ?> <rss version="2.0"> <channel> <title>Liftoff News</title> <link>http://liftoff.msf...

Does any one know of a template for purchases, business card siz
I would like to be able to have a business card size card that I can punch the amount of purchase for my customers. After they make a certain amount of purchases I would collect them and they would receive a discount on their next purchase or a free item. On Sun, 7 Mar 2010 15:54:01 -0800, captured memories <captured memories@discussions.microsoft.com> wrote: >I would like to be able to have a business card size card that I can punch >the amount of purchase for my customers. After they make a certain amount of >purchases I would collect them and they would rece...

default text height comment
Is there a way to set the default text height for a new comment? Thanks mark (I've looked through help but can't find it if it's in there.) I assume you mean the font size? There is no text height available in Excel. A comment has a shape property and that is what you can use to change the font size. They didn't make it easy ... Range("D4").Comment.Shape.TextFrame.Characters.Font.Size = 12 -- Jim Cone Portland, Oregon USA http://www.mediafire.com/PrimitiveSoftware (free and commercial excel programs) "mp" <nospam@Thanks.com> wrote in message...

Exchange server crashed, please help....! Need to restore two priv.edb and pub.edb files into one....!
Hi Guys, I was wondering if I could get some help with the following problem we are having on our company. Here is the scenario; Our Windows NT 4.0 SP4a server running Exchange 5.5 SP4 crashed (Server 1) due to the exchange database reaching its 16 Gig's max limit. I went ahead and moved some mailboxes' e-mails to a few .pst files in order to make some space. This worked ok. Then, I decided to build another exchange server (Server 2) to moved some mailboxes and alleviate the load. Once the server was ready and configured as part of the current exchange site, I went ahead and move...

Run time error 5 : HQClient
When I double click HQ Client I have message box "Run time error 5 : Invalid procedure call or argument" how should I do? I used RMS 2.0 -- TOY2TOY ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Businesssolutions/Community/NewsGr...

Pivot Table Defaults
In the pivot table field list, whenever I create a new pivot table and I am inserting fields into the value area, I generally get as default field setting the 'Count' value. Is there a way to format the spreadsheet to make Excel recognize the data as all numbers so it defaults to the "Sum" function as opposed to "text"? Hi The rule that the PT Wizard adopts is, If all the values in the field being added to the data area are Numeric, then it uses Sum. If any of the values are Text or BLANK, then it uses Count. It sounds as though you have defin...

Installed Font does not display in Word 2007
Only 6 of of 8 recently installed TTF fonts will display in Word 2007 Are the missing ones variants like Italic or Bold? On Dec 25, 1:28=A0pm, GWHA <G...@discussions.microsoft.com> wrote: > Only 6 of of 8 recently installed TTF fonts will display in Word 2007 ...

delivery failure error
"The e-mail account does not exist at the organization this message was sent to" then says user unknown, even though other comupters don't have that problem. I get this error for a few clients, yet other clients can email the same address. I have Windows small business server 2000, I am pretty sure everything has updated patches. I know i security updates automatically. My clients are an updated Windows XP SR 1 with Office 2003(outlook) SR1. ...

LNK2001 and LNK2019 errors with template class
This is a multi-part message in MIME format. ------=_NextPart_000_00BB_01C695ED.3958DA70 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I have a smart pointer class that uses template functions that works = fine under VC6 but it not linking under VS2005. 1>TestGridToolkitView.obj : error LNK2019: unresolved external symbol = "void __cdecl PrismGCSmartPointer(class CPrismSmartPointer<class = CDialog> &)" = (?PrismGCSmartPointer@@YAXAAV?$CPrismSmartPointer@VCDialog@@@@@Z) = referenced in function "protected: __...

Setting Defaults in New Item Wizard
How can I set a default value in the New Item Wizard? I want to always use a barcode type that is about 10 down from the top and I want Taxable Item to always be checked. Help... Good question, I need an answer too. "A StanTech Associate" wrote: > How can I set a default value in the New Item Wizard? I want to always use a > barcode type that is about 10 down from the top and I want Taxable Item to > always be checked. Help... You can set the default sales tax under Manager, File, Configuration, Sales Tax, Default item tax group. To set a default barcode type yo...

Error with Bold
What's wrong? With Worksheets("Recent") Range(Cells(1, 1), Cells(1, 2)).Font.FontStyle = "Bold" End with Take a look at the activesheet. I bet that range is bolded. But if you want Recent to be the sheet with the change, add a couple of dots. With Worksheets("Recent") .Range(.Cells(1, 1), .Cells(1, 2)).Font.FontStyle = "Bold" End With Without those dots, the range refers to the activesheet (if the code is in a general module). crapit wrote: > > What's wrong? > With Worksheets("Recent") > Range(Cells(1...

on Writexml error
(Type your message here) Hi all, I have a XML file as a datasource. I read that file using dataset.readxml.Then in that dataset I make some changes. Now I want to write that changed dataset by overwriting the file that was created initially. I someone please tell me how to do it. -------------------------------- From: ratnesh gupta ----------------------- Posted by a user from .NET 247 (http://www.dotnet247.com/) <Id>sCyOfoucUUyYsxAsNxg9AA==</Id> ...

Default User object security
Windows 2003 SP2 I am trying to fix a problem where delegation of control is not working properly to usr OUs. I ca't seem to keep permissions on user account objects that allow user accounts to be moved between OUs. I think it may be related to protected account membership on the user objects themselves. ALso the "inherit permissions from parent" is unchecked on user objects. Certain user new user objects work fine and are inheriting. What are the default security to use on user objects so that i can remvoe membership from protected groups and how should I a...

Error loading outlook 2003
Hey Guys need a little help I'm running office 2003 with outlook, I'm using my own exchange server, everytime I load up outlook on one of my workstations it loads up fine until I hit the inbox, once I do that Outlook closes down, I check in the event view and got this error message: "The MOF file created for the outlook service could not be loaded. The error code returned by the MOF Complier is contained in the Record Data. Before the performance counters of this service can be collected by WMI the MOF file will need to be loaded manually." Anyone know a fix inste...

Excel error 1706
Whenever I try to start excel on my computer it displays an error message and it shuts itself down, any other program from the office pack works properly, except for the one I mentioned. I reinstalled it and it does the exact same thing. Thanks in advance. ...