Results 1 to 4 of 4
  1. #1
    Robeen is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596

    Unhappy Appropriate Event in which to Update current record on Datasheet Form.

    Hi!



    I have a Form that is in Datasheet 'mode'.
    It sits in another Form that has 'header' information.
    Each Form has as its record source a simple query based on a separate table.
    For each Header record on the main form - the user will choose one or more items from the embedded datasheet.
    This is not a Master-Detail Form. The Datasheet form merely shows available choices that the user can select.

    The first field in the datasheet is a checkbox/Yes-No control.
    I have code in the clicked event of the checkbox that puts various data from the main form and the embedded datasheet form into a couple of other tables in the DB. All working well.

    What I would like to do is:
    When the checkbox for a record is checked on the embedded datasheet -
    add a value from the Main form . . .
    to another field in the SAME record for which I just checked the checkbox on the datasheet.

    I have put the Insert code in the LostFocus Event of the Checkbox control . . . and it is working . . .
    BUT . . .
    The LostFocus Event is firing twice:
    The first time, it is writing the correct value from the Main Form to the table - but for the very first record on the datasheet [which I did not click]
    The second time LostFocus fires, it is writing the correct data to the correct record [the one in which I clicked the checkbox].

    I only need the value to go to the record for which I clicked the checkbox.

    Should I be putting this code in another event altogether?

    . .. scratching head . . .


    I haven't been on here a while - I hope you are all well . . . Happy New Year!!

  2. #2
    Robeen is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    In short . . .
    You clicked on a checkbox in one of the rows of the datasheet,
    I used the clicked event of the checkbox to write data from the datasheet & main form to different tables,
    I also want to write other data to another field in the same record that you checked the checkbox in - before you get off the record and check another record.
    What event should I put this update code in?

    I hope that makes it easier.
    Last edited by Robeen; 01-14-2015 at 02:36 PM. Reason: clarify

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    Maybe in the Click or AfterUpdate event of the checkbox. In VBA:

    Me.anotherfieldname = something
    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.

  4. #4
    Robeen is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Thanks, June!
    I just put it in the AfterUpdate() event and it worked fine.
    Appreciate your help.
    Hope you're doing well!

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

Similar Threads

  1. Replies: 2
    Last Post: 04-08-2015, 04:06 PM
  2. Replies: 14
    Last Post: 08-12-2014, 06:33 AM
  3. Replies: 7
    Last Post: 05-08-2014, 10:34 AM
  4. Replies: 2
    Last Post: 03-05-2013, 04:11 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