Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. DataType mismatch in criteria expression Access 2007 - VBA

DataType mismatch in criteria expression Access 2007 - VBA

Scheduled Pinned Locked Moved Database
helpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    scorp_scorp
    wrote on last edited by
    #1

    Dear Alll, i have the following: Set t = classdb.OpenRecordset("select unit_price from contract_details where item_classification_id = '" & Me.Text12.Value & "'";) when it runs it give me this error : DataType mismatch in criteria expression but the item_classification_id is a number feild (using access 2007), and Me.text12.value returns an integer. i have checked it 100's of time, it drives crazy... may be am missing a thing , am not that good in coding, any clues ??? Regards.

    0 will always beats the 1.

    G 1 Reply Last reply
    0
    • S scorp_scorp

      Dear Alll, i have the following: Set t = classdb.OpenRecordset("select unit_price from contract_details where item_classification_id = '" & Me.Text12.Value & "'";) when it runs it give me this error : DataType mismatch in criteria expression but the item_classification_id is a number feild (using access 2007), and Me.text12.value returns an integer. i have checked it 100's of time, it drives crazy... may be am missing a thing , am not that good in coding, any clues ??? Regards.

      0 will always beats the 1.

      G Offline
      G Offline
      Geoff Williams
      wrote on last edited by
      #2

      You are enclosing the value obtained from the Text12 textbox in single quotes. That's correct for a text value but not for a numeric value - hence your data mismatch error. Modify your query as follows:

      Set t = classdb.OpenRecordset("select unit_price from contract_details where item_classification_id = " & Me.Text12.Value & ";")

      S 1 Reply Last reply
      0
      • G Geoff Williams

        You are enclosing the value obtained from the Text12 textbox in single quotes. That's correct for a text value but not for a numeric value - hence your data mismatch error. Modify your query as follows:

        Set t = classdb.OpenRecordset("select unit_price from contract_details where item_classification_id = " & Me.Text12.Value & ";")

        S Offline
        S Offline
        scorp_scorp
        wrote on last edited by
        #3

        thanks aloooooot regards,

        0 will always beats the 1.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups