Results 1 to 4 of 4
  1. #1
    hascons is offline Novice
    Windows Vista Access 2007
    Join Date
    Dec 2009
    Posts
    9

    Updating a field on Datasheet

    Hello,



    I have a Main form with a Datasheet Subform to display records. One of the fields is a CheckBox. What I'm trying to do is update another field on the Datasheet when the value of the CheckBox Changes ( Eg. When true Add 3 to another field, When False Make other Field 0 ). I'm trying to use the AFTERUPDATE Property of the checkbox with recordset clone to accomplish this, but this doesn't seam to work.

    The following code is what I've tried

    Code:
    Private Sub Foreman_AfterUpdate()
    
    Set rst = Me.RecordsetClone
    
            If rst![Foreman] = True Then
                rst.Edit
                rst![AdditionalWage] = rst![AdditionalWage] + 3
                rst.Update
            Else
                rst.Edit
                rst![AdditionalWage] = 0
                rst.Update
            End If
        
    rst.Close
    Set rst = Nothing
    Is there another Property I should be using Instead?

    Steve

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Assuming the ComboBox is in the same record as the AdditionalWage control, you can reference it directly in the SubForm. No need to use the underlying RecordSet or its Clone.
    Me.AdditionalWage = Me.AdditionalWage + 3
    ...or...
    Me.AdditionalWage = 0

  3. #3
    hascons is offline Novice
    Windows Vista Access 2007
    Join Date
    Dec 2009
    Posts
    9
    Thank You Rural Guy

    I don't know why I thought a Datasheet was different than a single entry form.

    I just needed to add Me.Requery to update the sheet after the Check box click.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Me.Refresh would probably have been enough. Me.Requery takes you back to the beginning of the Recordset.

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

Similar Threads

  1. Replies: 10
    Last Post: 03-11-2014, 02:25 PM
  2. Replies: 7
    Last Post: 03-02-2014, 08:47 PM
  3. Replies: 1
    Last Post: 02-17-2014, 01:00 PM
  4. Replies: 9
    Last Post: 02-28-2012, 01:45 PM
  5. Updating form from datasheet
    By srcacuser in forum Forms
    Replies: 10
    Last Post: 11-16-2011, 12:59 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