Results 1 to 4 of 4
  1. #1
    sunny is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    15

    Error called Expected end of statement in update query?

    Hi All,
    I am trying to update my record through form and for that I have written a code also.But in update command I am getting compile error.Some syntex problem.any one please correct it.
    Dim rs As DAO.Recordset, db As DAO.Database
    Dim res As Boolean
    Dim query As String
    Dim temp
    Set db = CurrentDb
    query = " Update User set Last_Name=" & txtUserId & ",First_Name= " & txtFirstName& ",Email_Id= " & txtEmailId & "',User_Type= "cmbUserType & " from User where User_Id=" & txtUserId & ""
    Debug.Print query
    db.Execute query
    ''If txtUserId = "" Then


    ''MsgBox "Please select Record first"
    'If Err.Number = 0 Then
    'MsgBox "Record Updated successfully." & db.RecordsAffected
    'Else
    'MsgBox "Record not Updated The error is: " & Err.DESCRIPTION
    'End If
    End Sub
    Thanks

  2. #2
    dsmacs is offline Advanced Beginner
    Windows XP Access 2010 (version 14.0)
    Join Date
    Oct 2009
    Location
    Perth Western Australia
    Posts
    52
    In line User_ID = " & txtUserId & ""

    Add a semicolon between the inverted comma's;-

    User_ID = " & txtUserId & ";"

    I think you should place the test to see if a user has been selected first before executing the query? Include exit sub and end if

  3. #3
    sunny is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    15
    Thanks for the reply..I changed what you have said.but its giving the error called "RUN TIME ERROR 3075" (SYNTEX ERROR MISSING OPERATOR IN QUERY EXPRESSION 'ADMIN FROM USER'.IN db.Execute query LINE.
    I am a beginner in vab access so dont know much about coding and syntex.please try to come up with a correct solution.I am using access 2003.
    THanks....

  4. #4
    dsmacs is offline Advanced Beginner
    Windows XP Access 2010 (version 14.0)
    Join Date
    Oct 2009
    Location
    Perth Western Australia
    Posts
    52
    Hi Sunny,

    Are you using the users surname as their ID number? What happens if you have two Smiths? set Last_Name=" & txtUserId ?

    Without seeing the table or form, I can suggest anything further. Place a copy with some sample data and someone will advise or email me at

    d [dot] mcdonald [at] ozemail [dot] com [dot] au

    Cheers
    Darren

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

Similar Threads

  1. Update Statement in form code
    By ksmith in forum Programming
    Replies: 9
    Last Post: 11-07-2011, 12:04 PM
  2. Syntax Error while calling sub: Expected: =
    By cowboy in forum Programming
    Replies: 3
    Last Post: 07-12-2010, 02:21 PM
  3. Replies: 2
    Last Post: 06-14-2010, 09:38 PM
  4. Replies: 2
    Last Post: 12-03-2009, 05:06 PM
  5. update table in loop based on IF statement
    By LALouw in forum Access
    Replies: 0
    Last Post: 07-26-2009, 08:46 PM

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