Results 1 to 4 of 4
  1. #1
    Mikejsinclair's Avatar
    Mikejsinclair is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Sep 2016
    Posts
    2

    Arrow Data Type Mismatch on Criteria Expression

    Hi,



    I'm not extremely proficient in Access and wondered if someone could assist with an error message I'm getting when trying to open a form based on the value selected by a user on a subform in control Record_ID.

    The code is as follows:


    Code:
    DoCmd.OpenForm "Frm_MyForm", acViewNormal, , "Record_ID = " & Record_ID.Value
    Hope the above makes sense

    Many thanks

    MJS

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    Days mismatch usu means you are trying to assign a string to a number.
    looking at the code ,this is probably happening at:
    record_id=" & record_id.value.

    DONT use the .value of a text box. Just use the name, the value is understood.
    if the textbox is null, this could fail.
    if the textbox name is spelled wrong, it will fail.

  3. #3
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Also note that selecting criteria from a Subform can get a little tricky:
    https://bytes.com/topic/access/answe...coming-subform
    http://www.utteraccess.com/forum/ind...wtopic=2034569

  4. #4
    Mikejsinclair's Avatar
    Mikejsinclair is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Sep 2016
    Posts
    2
    Many thanks Guys, between the both of you we got there in the end. I referenced the subform correctly and also changed the syntax so that the criteria in the target form wasn't enclosed in quotes (thereby converting it to a text string). the revised code looks like this

    Code:
    Dim Str_ImpID As StringStr_ImpID = Forms!Frm_TBParameters!Frm_ImpHistory.Form!Import_ID
    DoCmd.OpenForm "Frm_TBView", acViewNormal, , Import_ID = Str_ImpID
    Thanks again

    MJS

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

Similar Threads

  1. Data Type Mismatch in criteria expression
    By gaker10 in forum Queries
    Replies: 3
    Last Post: 03-05-2015, 01:54 PM
  2. Replies: 5
    Last Post: 02-25-2015, 08:42 AM
  3. Data type mismatch in criteria expression
    By bobt_1234 in forum Queries
    Replies: 3
    Last Post: 02-13-2012, 03:37 PM
  4. Data Type mismatch in criteria expression
    By elb1999 in forum Queries
    Replies: 2
    Last Post: 01-20-2012, 02:38 PM
  5. Data type mismatch in criteria expression
    By buienxg in forum Access
    Replies: 2
    Last Post: 11-22-2011, 10:29 AM

Tags for this Thread

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