Results 1 to 5 of 5
  1. #1
    dgmdvm is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2014
    Posts
    84

    Type Mismatch problem

    I am using a simple form (form1) with a single combo box (CmboSearch) in it to perform a search of client names. When the user clicks on the correct name from the combo box, a new form (form2) should open with that client's data populating the fields. My code correctly brings up all the names in the combo box but when I click on the name I want, I get a Type mismatch error. When I click on ok in the error msgbox, form2 does open and it has the proper data in its fields. I have tried all sorts of variations in the code but I have not been able to get the error to go away. The combo box is based on a query of 2 tables, tlbClients, and tblpersons. The combo box row consists of [CLid] the primary key for the tblclients, [CL_last_name] from tblclients, [Cl_firstName] from tblPersons, and [primaryContact] from tblpersons.

    here is the code:
    Code:
    Option Compare DatabaseOption Explicit
    
    
    Private Sub CmboSearch_AfterUpdate()
    
    
        ' Find the record that matches the control.
        Dim rs As Object
    On Error GoTo Err_CmboSearch_AfterUpdate
    
    
        Set rs = Me.Recordset.Clone
        rs.FindFirst "[ClID] = " & str(Nz(Me![Cl_LastName], 0))
       
        
        If Not rs.EOF Then
          Me.Bookmark = rs.Bookmark
        
        
        End If
     
        Me.Refresh
        
        Set rs = Nothing
     
    Exit_CmboSearch_AfterUpdate:
        Exit Sub
    
    
    Err_CmboSearch_AfterUpdate:
        MsgBox Err.Description
        Resume Exit_CmboSearch_AfterUpdate
            
    End Sub
    
    
    
    
    Private Sub CmboSearch_Click()
    DoCmd.OpenForm "Client_intake_form", acNormal, , "ClID=" & Me.CmboSearch, acFormEdit, acWindowNormal
    End Sub
    What am I doing wrong?

  2. #2
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    The combo box row consists of [CLid] the primary key for the tblclients
    Is "CLid" a number or Text???

  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    After looking at your code, I see some errors on the CmboSearch_AfterUpdate() code.

    Delete the sub "CmboSearch_Click()".
    Then change the after update code to
    Code:
    Private Sub CmboSearch_AfterUpdate()
       DoCmd.OpenForm "Client_intake_form", acNormal, , "ClID=" & Me.CmboSearch, acFormEdit, acWindowNormal
    End Sub

  4. #4
    dgmdvm is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2014
    Posts
    84
    ClID is an autonumber and the primary key (sorry I forgot to mention that)

    So I dumped all the code in the after update sub and placed the open form statement in and it works fine. Now I am wondering why I had all that code in the after update field anyway? I have always used that code in forms to search for records. Doesn't seem to be necessary, at least not here.

    Thanks for the help.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    It's useful if you want to 'go to' record on form the code is behind.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Type 13 (Type Mismatch) error
    By sdel_nevo in forum Programming
    Replies: 5
    Last Post: 01-22-2016, 10:01 AM
  2. type mismatch
    By seeker63 in forum Programming
    Replies: 2
    Last Post: 12-05-2013, 02:54 PM
  3. Replies: 6
    Last Post: 11-16-2013, 06:06 PM
  4. type mismatch
    By slimjen in forum Forms
    Replies: 21
    Last Post: 07-24-2012, 03:14 PM
  5. Type Mismatch - HELP!
    By jgelpi in forum Programming
    Replies: 3
    Last Post: 07-17-2009, 03:53 PM

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