Results 1 to 6 of 6
  1. #1
    pratim09 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Apr 2011
    Posts
    30

    Update query problem

    I have a form with prepopulated value with few fields which opens up on click of a particular record in previous form.One of the fields in the current form is Trackingid whose text field is disabled which will come from previous form and that is the primary key of the table and it is a autonumber datatype . Now I want to modify a field release name in the current form for that particular tracking id .Below is the update query

    strSQL = "UPDATE HoursTracking SET [Release Name] = '" & txtReleaseName & "' WHERE TrackingId = '" & txtReleaseName & "'"

    DoCmd.RunSQL strSQL



    I am getting the below error

    Datatype mismatch in criteria expression.

    I have TrackingId and txtReleaseName as String and in database Tracking Id column is autonumber and Release Name column is Text


    Plz help ..I am stuck on this for 2 hours now.

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Is the release name in the original form? You can bring that into the second form that opens as well. Is the second form bound or unbound? I assume that the second form is unbound and hence why you need the update query. Do you have a button on the form that executes the update query?

    Why don't you have the trackingID control referenced in the WHERE clause of the update query? This is what you currently have:

    Code:
    strSQL = "UPDATE HoursTracking SET [Release Name] = '" & txtReleaseName & "' WHERE TrackingId = '" & txtReleaseName & "'"
    
    Shouldn't it be this:

    Code:
    strSQL = "UPDATE HoursTracking SET [Release Name] = '" & me.txtReleaseName & "' WHERE TrackingId = " & me.trackingID
    
    I've added the me. shortcuts to refer to the current form

  3. #3
    pratim09 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Apr 2011
    Posts
    30
    Soory the update statement i gave was little wrong the actual one is

    strSQL = "UPDATE HoursTracking SET [Release Name] = '" & txtReleaseName & "' WHERE TrackingId = '" & Me.TrackingId & "'"

    and still its not working .

    I have the release name in the current form and if I print the strSQL through msgbox i am getting the below

    UPDATE HoursTracking SET [Release Name] = '2010MR-NOV' WHERE TrackingId = '9792'

    I am using the code in the click eventy of a modify button in the form

  4. #4
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You said that the trackingID field (in the table) is autonumber, as such, the trackingID value must not be enclosed in the single quotes as you showed:

    UPDATE HoursTracking SET [Release Name] = '2010MR-NOV' WHERE TrackingId = '9792'

  5. #5
    pratim09 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Apr 2011
    Posts
    30
    Thanks a lot ....

  6. #6
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You're welcome.

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

Similar Threads

  1. update querry Problem
    By newtoAccess in forum Queries
    Replies: 1
    Last Post: 04-04-2011, 09:33 AM
  2. Front End Update Problem
    By Randy in forum Access
    Replies: 2
    Last Post: 02-12-2011, 09:46 PM
  3. Problem with Update Query?
    By emarchant in forum Access
    Replies: 7
    Last Post: 10-08-2010, 12:51 PM
  4. Data Update Problem
    By Nosaj08 in forum Forms
    Replies: 3
    Last Post: 05-15-2009, 02:06 PM
  5. Update Query problem
    By sollem1 in forum Queries
    Replies: 0
    Last Post: 11-08-2007, 10:16 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