Results 1 to 6 of 6
  1. #1
    Juan4412 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    209

    Error Message

    I have a combo box that will search through the records in my table, and if the search item is located it will display the record. If the search item is not found, I get the following error:



    The following runtime error occurred:
    Number: 94
    Description: Invalid use of Null
    Object Type: Form
    Procedure: Combo48_AfterUpdate
    Object: frm_111
    Contact the application administrator


    Can someone tell me how to make this error not display, and just display "not found" or something like that or "not in the database" whatever the default message is. I tried recreating my form, and i still get the error.

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,527
    What's the code behind the combo?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Juan4412 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    209
    Code Behind Cbo Box

    Code:
       Private Sub Combo48_AfterUpdate()  
    On Error GoTo Err_Combo48_AfterUpdate 
           ' Find the record that matches the control.  
        Dim rs As Object 
           Set rs = Me.Recordset.Clone  
        rs.FindFirst "[id] = " & Str(Me![Combo48])  
        Me.Bookmark = rs.Bookmark 
       Exit_Combo48_AfterUpdate:  
        Exit Sub 
       Err_Combo48_AfterUpdate:  
        Select Case Err.Number  
        Case 0  
            Resume Next  
        Case Else  
            Call gsErrorHandler(Err, Application.CurrentObjectName, Application.CurrentObjectType, "Combo48_AfterUpdate")  
        End Select 
           Resume Exit_Combo48_AfterUpdate 
        
       End Sub

  4. #4
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You are not checking the NoMatch property after doing a FindFirst. Try this:

    Code:
    Private Sub Combo48_AfterUpdate()
       On Error GoTo Err_Combo48_AfterUpdate
       ' Find the record that matches the control.
       Dim rs As Object
       Set rs = Me.Recordset.Clone
       rs.FindFirst "[id] = " & Str(Me![Combo48])
       'check to see if record found
       If rs.NoMatch Then
          MsgBox "No record matched"
       Else
          Me.Bookmark = rs.Bookmark
       End If
    
    Exit_Combo48_AfterUpdate:
       Set rs = Nothing
       Exit Sub
    Err_Combo48_AfterUpdate:
       Select Case Err.Number
          Case 0
             Resume Next
          Case Else
             Call gsErrorHandler(Err, Application.CurrentObjectName, Application.CurrentObjectType, "Combo48_AfterUpdate")
       End Select
       Resume Exit_Combo48_AfterUpdate
    
    End Sub

  5. #5
    Juan4412 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    209
    Adding those lines of code, causes the error message to go away. Thanks!!!

    My next question pertaining to this is, when the search item is not located, it is displaying a message that says,
    "
    The text you entered isn’t an item in the list.

    Select an item from the lsit, or enter text that matches one of the listed items."

    Is there a way for me to change the message that is displayed?

  6. #6
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    It sounds like the limit to list property is set to YES. Change it to NO.

    Read about the "Limit To List" property in Help.

    You could change the combo box to a text box and add a button with the search code. You wouldn't get the error message, but you would have to type in the data you want to search for.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Error message when importing
    By ljenkins23 in forum Access
    Replies: 5
    Last Post: 06-10-2010, 09:30 AM
  2. error message
    By ngeng4 in forum Forms
    Replies: 85
    Last Post: 03-25-2010, 06:47 AM
  3. where do i start with this error message?
    By Student4Life in forum Access
    Replies: 0
    Last Post: 01-09-2009, 04:12 PM
  4. FROM Clause error message
    By skylite in forum Queries
    Replies: 2
    Last Post: 10-23-2008, 05:47 AM
  5. If / Then Error Message
    By Schwagr in forum Forms
    Replies: 4
    Last Post: 03-30-2006, 06:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums