Results 1 to 4 of 4
  1. #1
    c3pse is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    2

    Question Run Update Query on Current Record in Form

    Hi,



    I am have a little bit of experience with Access but I need some help with a database for a school IPT assignment.

    Basically I have a button on a form that I want to run an Update query on the currently displayed record.
    I have been using this SQL to update but it updates all records.
    Code:
    UPDATE BlueSlips SET Detention = False;
    I have tried to using code #2 but it comes up with Compile Error and highlights the Private Sub line.

    Code #2
    Code:
    strSQL = strSQL & "UPDATE BlueSlips SET Detention = False; WHERE BlueSlipsID = " & Me.BlueSlipsID
    Any help would be appreciated
    Thanks.

  2. #2
    Datagopherdan is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Dec 2008
    Posts
    220
    Try this. I'm assuming that "Detention" is a Yes/No field.

    Code:
    CurrentDb.Execute "UPDATE BlueSlips SET Detention = 0 " & _
    "WHERE BlueSlipsID = " & Me.BlueSlipsID

  3. #3
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    You can include field "Detention" in the form (if don't want to show this field, hide it).
    and code like this:

    detention=false

  4. #4
    c3pse is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    2
    Quote Originally Posted by weekend00 View Post
    You can include field "Detention" in the form (if don't want to show this field, hide it).
    and code like this:

    detention=false
    Could you elaborate on this please.

    Thanks

    EDIT: I have used this but now it comes up with 'This recordset is not updateable'. I have tracked this to the query because as I have tried to uncheck the box it comes up with the same thing in the status bar.

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

Similar Threads

  1. Query based on current record in form
    By bhsvendbo in forum Queries
    Replies: 1
    Last Post: 06-01-2010, 11:20 AM
  2. Replies: 0
    Last Post: 05-04-2010, 06:39 AM
  3. Replies: 3
    Last Post: 02-28-2010, 11:05 PM
  4. Open form to current record
    By rbpd5015 in forum Access
    Replies: 1
    Last Post: 08-28-2009, 01:53 AM
  5. How to output only current record in query
    By mslieder in forum Access
    Replies: 0
    Last Post: 01-20-2006, 05:48 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