Results 1 to 6 of 6
  1. #1
    Dan01 is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    5

    Help with update query

    Hello, I am very new to Access and havent tackled SQl in some years now. I am creating a database/application for my workplace with a login system and have hit a bit of a block.

    I have the following code in SQL view and when i run it I get the error....Operation must be an updateable query. Please could someone point out where I am going wrong, heads kinda hurting now

    All i need to do it take a few details from one table (User - this table is linked to a backend db) and place them into another table (current_user - this is in the Frontend db file) when the user logs in

    Here is the code I have

    UPDATE [current_user] SET [current_user].F_name = (SELECT User.F_name
    FROM [User]


    WHERE User.Username = (
    SELECT current_user.curr_username
    FROM [current_user]);
    );

    Thank you in advance

    Dan
    Last edited by June7; 03-01-2013 at 12:44 PM.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    For one thing nested query cannot have semi-colon. For another, the query makes no sense to me.

    How do you know who the user logging is?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Dan01 is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    5
    Hi, ok a quick overview of the app is as follows...

    I have follwed an example of a vb login script, and implemented it sucessfully. The login script looks down a table of usernames/passwords/user details (table called User). If it finds the match, access is granted. I am looking to form some kind of "session" for the user, so have a separate table called current_user, that gets updated upon login with the successful login details.

    So, the table called User holds all users details. I wanted, upon sucessful login (having the current_user table populated direct from the login form) to have the details that match the current_user login name (from the User table) update into the current_user table also.

    That way I can refer to the user throughout the "session". The current_user table is emptied with an AutoExec upon app startup

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    If you don't retain the session table records for historical purposes, why have it? Just have those fields in the User table. That's what I do. I also don't require repeat users to log in. I grab their username from the network and use that to find match in user table, if not there then they are a new user and they are presented with log in form. I use Environ("USERNAME") to get user ID from network.

    This is a common topic in forum. Search for keywords: Environ USERNAME; postings by: June7

    Here is one that has my code https://www.accessforums.net/access/...gin-23585.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Dan01 is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    5
    Its something I will look into surely. The prob with that is as of right now I am creating on a standalone machine, not actually at work. not sure if i can grab a network name off a normal pc, it its not on a netwrok. The current user table i mad is just to refer to while the user is active, so i can echo out names at things like that. Also as stated the current user runs on the frontend, the main user table is on the backend, with many copies of the application which may be in use at once, so i dont want the app to refer to one person at once, but many.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    The code is from a multi-user split database. I have also taken the db home and run it on my solo laptap. Have to change the table links and maybe a couple of other tweaks because I have 2010 at home. Actually been a while since I looked at it there, will check it out again this weekend.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 2
    Last Post: 08-30-2012, 07:59 AM
  2. Replies: 4
    Last Post: 11-10-2011, 03:41 PM
  3. Replies: 2
    Last Post: 09-21-2011, 01:30 PM
  4. Replies: 1
    Last Post: 08-19-2011, 12:16 PM
  5. Update 2 tables with one Update Query
    By Douglasrac in forum Queries
    Replies: 4
    Last Post: 04-14-2011, 08:33 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