Results 1 to 4 of 4
  1. #1
    kennethnaga is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    24

    Question OpenForm to Specific Record w/ Multiple Criteria | Run-time error '13': Type mismatch

    I have a main form (frm_Search) which contains two buttons (btnSearch and btnOpenRec) whose functions are to perform a keyword search and open form (frm_Sch1) to a selected record for editing, respectively. The keyword search button filters a subform (SubSearchForm) by Index&Facility (Short text, ie. 101A) and Reporting Year (Number, ie. 2017). Users are able to select the desired record in the subform and displays it in the txtIF and txtRY textboxes (linked by control source).

    Here is my code.

    DoCmd.OpenForm "frm_Sch1", acNormal, , "[Index&Facility=]'" & Me.txtIF & "'" And "[Reporting Year=]" & Me.txtRY, acFormEdit, acWindowNormal

    I have tried every combination of quotes, looked into tables and made sure the fields are aligning correctly and are of the right type. Any suggestions would be greatly appreciated, I've been trying for the past two days with no luck.

    Note: When I run the code and hover my cursor over Me.txtIF and Me.txtRY a tooltip displays Me.txtIF = "101A" and Me.txtRY = 2017, respectively.



    This is my first time posting in the forum and I'm very new to access and not too sure as to how much information to include.

    Not sure if this is supposed to be in the programming sub-forum but this issue seems like a quick fix.

    THANK YOU!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Several issues, try:

    "[Index&Facility] = '" & Me.txtIF & "' And [Reporting Year] = " & Me.txtRY
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    kennethnaga is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    24
    It worked, thank you so much!!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help and welcome to the site by the way!

    FYI, spaces and symbols in your object names are not worth the trouble in the long run. They can be worked around with the brackets as you've had to do, but most of us avoid them and use camel case or underscores: ReportingYear or Reporting_Year, IndexAndFacility or IndexFacility
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 4
    Last Post: 07-28-2017, 06:17 PM
  2. Run-time error '13' Type mismatch
    By DCV0204 in forum Forms
    Replies: 4
    Last Post: 11-13-2013, 08:19 PM
  3. Replies: 4
    Last Post: 09-04-2012, 09:17 PM
  4. Run-time error '13': Type mismatch
    By uronmapu in forum Access
    Replies: 2
    Last Post: 07-10-2012, 07:59 PM
  5. Replies: 4
    Last Post: 10-26-2009, 05:27 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