Results 1 to 4 of 4
  1. #1
    MikeN is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2015
    Posts
    39

    Clear subform 'on-close'

    Hello all,
    I am relatively new to MS Access and have been teaching myself how to develop a database for inventory/'samples received' application. Just a little background - I'm a biologist. We give samples a unique identification number when we collect them. The form I have developed is used to scan in these new samples (though barcode) when they are brought back to the lab. The database tracks 'new' barcodes scanned and provides a detailed report on the number of each species that have been added to the inventory...it also allows us to track what samples we have on-hand.

    I am having trouble getting the subform (SamplesReceivedSubForm) to clear 'older' scanning events when a new event is initiated. Currently, both the subform (SamplesReceivedSubForm) are blank when main form (ScanEntryForm) is first opened; however, the subform autopopulates 'old' information as soon as the user makes any changes in the mainform (see images - first one is the form when it is just opened; second is after a selection has been made in the main form which results in autopopulated 'old' data in the subform).
    Attachment 19294 Attachment 19295
    I've searched for possible solutions but most seem to be wanting a button to clear -- which I do not. I want it to automatically clear all the data on the forms (on close, on load, or however...) and provide a fresh entry form whenever the user reopens the form.

    Currently, I have the parent form event clearing old data "on load" with the following code:
    Private Sub Form_Load()


    'clear previous records on load
    DoCmd.GoToRecord , , acNewRec
    End Sub
    I also have the main form and subform 'linked' via ScanPK (parent) and ScanFK (child)
    Attachment 19296
    Any suggestions? Thanks ahead of time!! I'm running Access 2007

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    If you don't want to see or navigate existing records, can set the subform for Single View and set DataEntry to Yes.
    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.

  3. #3
    MikeN is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2015
    Posts
    39
    I would like for the subform to show, and users to be able to navigate, all records that have been scanned for that specific form event. Ultimately, I want the main/subforms to just be blank when the form is opened...old data is old data and I don't want the user to have access to and/or see old data.
    This initially works as desired, but old subform data shows up once the user beings to create a new record in the main form. I forgot to mention something earlier though - the subform DOES clear automatically when the focus is moved to the subform. So, its a brief moment that old data appears -- no old data when the form is initially opened; old data appears in the subform as soon as the user starts entering data in the main form; then, old data disappears from the subform when the focus moves to the subform. I have it set up so focus cannot be moved to the subform until certain mainform criteria has been entered.

    I might have left out some important information earlier now that I think about it. The form is built off two tables - the main form is associated with ScanEntryTable with the primary key just being autonumber...this number is the foreign key on the SamplesReceivedTable that is associated with data entered in the subform.

  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,816
    I had assumed that was the form/subform arrangement.

    But I am confused. Post statements seem contradictory:

    I would like for the subform to show, and users to be able to navigate, all records that have been scanned for that specific form event. Ultimately, I want the main/subforms to just be blank when the form is opened...old data is old data and I don't want the user to have access to and/or see old data.

    What is making the old data disappear?
    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: 7
    Last Post: 04-15-2014, 01:15 PM
  2. Replies: 2
    Last Post: 04-24-2013, 11:52 AM
  3. Replies: 11
    Last Post: 11-10-2012, 03:00 AM
  4. Hide subform and clear the space left
    By blueraincoat in forum Forms
    Replies: 7
    Last Post: 03-24-2011, 09:35 PM
  5. Replies: 2
    Last Post: 01-29-2010, 11:33 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