Results 1 to 3 of 3
  1. #1
    bell is offline Advanced Beginner
    Windows 7 64bit Access 2002
    Join Date
    Feb 2015
    Posts
    37

    Run-time error '13': Type mismatch when using a combo box

    Hi all,



    I had originally made a database that took in the primary key (Part Number) as a number, but I had to change that to text so that my Part Number could contain a dash.

    I had a Main Form I used to open up a specific Part Number entry, which worked when the Part Number was a number, but now when I use the combo box to pick a Part Number to open, I get the run-time error '13': Type mismatch.

    Code:
    Private Sub Combo4_AfterUpdate()
        ' Find the record that matches the control.
        Dim rs As Object
    
    
        Set rs = Me.Recordset.Clone
        rs.FindFirst "[Part Number] = " & Str(Nz(Me![Combo4], 0))
        If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    End Sub
    The error occurs at rs.FindFirst

    Could anyone help me correct this?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Parameters for text field need apostrophe delimiters, date fields use #, numbers don't have delimiters.

    rs.FindFirst "[Part Number] = '" & Nz(Me.Combo4, 0) & "'"

    Suggest you give controls meaningful names, especially the ones referenced in code or expressions.
    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.

  3. #3
    bell is offline Advanced Beginner
    Windows 7 64bit Access 2002
    Join Date
    Feb 2015
    Posts
    37
    Thank you, that worked

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

Similar Threads

  1. Run-time error '13' Type mismatch
    By DCV0204 in forum Forms
    Replies: 4
    Last Post: 11-13-2013, 08:19 PM
  2. Run-time error 13 type Mismatch
    By Jaron in forum Programming
    Replies: 2
    Last Post: 09-13-2013, 02:33 PM
  3. Run-time error 13: type mismatch
    By ehe in forum Programming
    Replies: 3
    Last Post: 01-13-2013, 12:58 AM
  4. run-time error '13' type mismatch
    By teebumble in forum Forms
    Replies: 8
    Last Post: 12-03-2012, 01:18 PM
  5. run-time error 13 , type mismatch
    By Compufreak in forum Programming
    Replies: 8
    Last Post: 08-13-2012, 12:17 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