Results 1 to 4 of 4
  1. #1
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194

    Null all of one control in subform with button

    WOW so i tried for 3 hours to do this and failed miserably

    - I have a form [Main] with a subform [sub]

    [sub] has a control (textbox) called [rcvd]

    It is a continuous subform.

    I want the user to be able to put all values in then if they want to just cancel and clear it pretty much runs

    me.[sub].[rcvd] = ""

    I know the above doesnt actually work but i have tried:


    All kinds of referencing like above,
    creating a public function in [sub] that DOES clear the control ( me.[rcvd] = "")

    im guessing i need an update query?? I just thought my idea was sound then it just didnt work lol

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    use a query...put in all values to the sub table with an append (using the master ID)
    or delete all values with a delete query (using the master ID)

    the me.[sub].[rcvd] = ?? will ONLY work on 1 record.

  3. #3
    knarfreppep is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Feb 2015
    Location
    Adelaide, Australia
    Posts
    106
    Quote Originally Posted by ranman256 View Post
    me.[sub].[rcvd] = ?? will ONLY work on 1 record.
    And I think that one record will be left in 'being edited' mode.

    Try -
    DoCmd.RunSQL "UPDATE tblChildren SET rcvd = Null WHERE lngParentID = " & Main.txtID (if your IDs are, as they should be, numbers)

    OR

    DoCmd.RunSQL "UPDATE tblChildren SET rcvd = Null WHERE strParentID = """ & Main.txtID & """" (if your IDs are, as they should NOT be, strings)

  4. #4
    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
    DoCmd.RunSQL will trigger warning messages. Options:

    DoCmd.SetWarnings = False
    DoCmd.RunSQL ...
    DoCmd.SetWarnings = True

    or

    CurrentDb.Execute "UPDATE ..."

    In either case, then refresh the form

    Me.Sub.Refresh

    However, as knarfreppep notes, if editing was initiated and that record is still in edit mode, after the SQL runs will possibly generate an 'edited by another user' error when that record attempts to commit. Either first commit the record or undo the edits.

    'Sub' is not a very informative name.
    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: 8
    Last Post: 06-19-2015, 02:19 AM
  2. Replies: 2
    Last Post: 11-14-2014, 03:07 PM
  3. Replies: 1
    Last Post: 09-12-2014, 06:09 AM
  4. Replies: 10
    Last Post: 02-20-2013, 07:04 AM
  5. Replies: 3
    Last Post: 03-29-2012, 12:40 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