Results 1 to 2 of 2
  1. #1
    jtm013 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Aug 2014
    Posts
    117

    syntax error on Recordset

    Hello,



    I have a piece of code which is writing to a table.

    Code:
    Set rst = CurrentDb.OpenRecordset("tLogUser", , dbAppendOnly)            rst.AddNew
                    rst![LogOutTime] = Now()
                    rst![UserName] = Environ("UserName")
                    rst![LocationName] = Environ("ComputerName")
                    rst![LoginName] = "'" & DLookup("EmpID", "tblLogin", "locationCurrent = '" & Environ("ComputerName") & "'") & "'"
                    rst.Update
                rst.Close
    I recently added the field LoginName to this table. The code had worked well and all previous aspects of the code continue to work. However, All that is populated in the field LoginName is a single ". I have tried several variations and have made no progress.

    Thanks for any and all assistance.

    ________

    Nevermind- I found the problem I dropped the "'" from the above code. I had done this earlier, but I realized that my calling procedures were out of order so the field location current was already emptied by the time this piece of code ran. Anyway it is solved.
    Last edited by jtm013; 07-09-2015 at 02:18 PM. Reason: Fixed it.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    You don't want the outer quotes:

    rst![LoginName] = DLookup("EmpID", "tblLogin", "locationCurrent = '" & Environ("ComputerName") & "'")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 11
    Last Post: 05-01-2014, 11:56 AM
  2. Replies: 3
    Last Post: 01-23-2014, 07:49 AM
  3. Replies: 6
    Last Post: 05-30-2012, 12:32 PM
  4. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM
  5. Syntax Error Help with Recordset
    By ajetrumpet in forum Programming
    Replies: 11
    Last Post: 09-08-2010, 02:39 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