Update Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • UAlbanyMBA
    New Member
    • Nov 2006
    • 31

    Update Error

    I am trying to update a record but I keep receiving an error, "Data type mismatch in criteria expression." Here is the code:

    Code:
     DoCmd.RunSQL ("Update Caller2 SET Ext = '" & Me!txtExt & "' where CallerID ='" & GlobalCID & "'")
    It has something to do with the where clause. The code "worked" when I forgot to include it. I need to be able to update a bunch of fields, but broke them down one by one to debug, and reached the conclusion it is the where clause. GlobalCID is being assigned properly. The only thing I can think of is CallerID is an autonumber, but I don;t know.

    Any help??
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Originally posted by UAlbanyMBA
    I am trying to update a record but I keep receiving an error, "Data type mismatch in criteria expression." Here is the code:

    Code:
     DoCmd.RunSQL ("Update Caller2 SET Ext = '" & Me!txtExt & "' where CallerID ='" & GlobalCID & "'")
    It has something to do with the where clause. The code "worked" when I forgot to include it. I need to be able to update a bunch of fields, but broke them down one by one to debug, and reached the conclusion it is the where clause. GlobalCID is being assigned properly. The only thing I can think of is CallerID is an autonumber, but I don;t know.

    Any help??
    If CallerID is a number then you have to leave off those single quotes you're using to enclose it. The single quotes tell the system that it's a string and will treat it as such.

    Comment

    • UAlbanyMBA
      New Member
      • Nov 2006
      • 31

      #3
      Such a green mistake. Thanks, and sorry for the hassle.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Originally posted by UAlbanyMBA
        Such a green mistake. Thanks, and sorry for the hassle.
        It's not a problem at all. Good luck.

        Comment

        Working...