Results 1 to 15 of 15
  1. #1
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231

    How do I insure that my Update Query will only update the current record?


    I have a multi-user DB that users may be using at various times. The concept is for recording grades at the end of a period (quarter in this case). Once the grade and date have been entered a report is printed for that student. In order to prevent that same report from printing again I have a Yes/No filed to prevent that. However, if more than 1 user is doing this, when user 1 runs the report and update, user 2's record will also get updated and prevent the report from being produced. How do I insure that only the record for user 1 is updated? I am not up on VBA coding yet, but am willing to try if I get good instructions. Thanks.

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Add a reference to the form in your query. Here is a screenshot example.


    HTH
    Attached Thumbnails Attached Thumbnails qryUpdateTableExample.jpg  

  3. #3
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231
    I can't read the criteria row on my monitor. Could you please type it out?

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    use the record key.

  5. #5
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231
    I don't know what you mean. Where and how would I use the record key?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    The unique ID for the record.

    UPDATE tablename SET fieldname=True WHERE ID = Forms!formname!ID;

    Or use the userID to restrict the record(s) that will be updated.

    UPDATE tablename SET fieldname=True WHERE userID = Forms!formname!userID;
    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.

  7. #7
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231
    I am having difficulty figuring out "ID" following the WHERE. Here is how I changed my SQL statement:
    UPDATE [Student Course History] SET [Student Course History].Print1 = Yes
    Where [sde campus query]![localid] = forms![course completion main form]!localid;

    What am I missing?

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    You are updating [Student Course History] but WHERE clause references a field in [sde campus query]. Unless [Student Course History] is a query that includes [sde campus query], this won't work.

    I presume [Student Course History] is a table. Is localid a field in that table?
    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.

  9. #9
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231
    Yes it is. I am using a form/subform where sde campus query is the data source for the form and Student Course History is the source for the subform; linked by LocalId. There are 4 quarters in a grading sequence and therefore there may be up to 4 records per student per course in the history.

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Did you mean [Student Course History] is a table?

    Doesn't really make sense to reference a table for the field to update but reference a field in another table/query as filter criteria. Referencing two datasets in same query without a JOIN clause causes Cartesian relationship.
    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.

  11. #11
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231
    Main form source is not updated, only subform source. There may be more than 1 user opening the form at the same time. It is even possible that they could be working on the same student, but not the same subject. Once the data is entered into the subform a report is printed and then I want to update the subform record just printed and only that record.

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    That doesn't really address my question or comment.
    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.

  13. #13
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231
    Sorry about that. Yes it is a table. and the two tables are joined by LocalId.

  14. #14
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Options for editing record programmatically:

    1. if the field is included in the form RecordSource use SetValue action - with macro in design, click Show All Actions

    2. if the table you want to edit is not in the form RecordSource, need to run an SQL UPDATE action.

    Whichever approach suits the situation, add action to the end of the Print button macro. Not seeing either there now.

    There is no filter criteria for the report. It shows all students.
    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.

  15. #15
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231
    I will use the same criteria to only print the current record and will be checking the PRINTED (Yes/No) switch for No.

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

Similar Threads

  1. Update the current record.
    By Access_Blaster in forum Forms
    Replies: 3
    Last Post: 07-21-2013, 05:33 PM
  2. Replies: 13
    Last Post: 12-17-2012, 07:52 PM
  3. Replies: 3
    Last Post: 09-18-2011, 03:46 PM
  4. Current Record Update Issue
    By SALPBE in forum Programming
    Replies: 0
    Last Post: 02-23-2011, 03:02 PM
  5. Run Update Query on Current Record in Form
    By c3pse in forum Queries
    Replies: 3
    Last Post: 08-14-2010, 05:40 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