Subform to open on new record

Posted on 2011-10-20
Last Modified: 2012-05-12
My mother form has a comments form which links to the tblComments.
The mother form also has a control that opens a daughter form which also has a similar comments form on it.
Presently when I make a comment while on the mother form and then navigate to the daughter form, the same comment that was active on the mother form is still active.
The same is the case if I make a comment on the daughter form and navigate to the mother form.
I want that each time the mother form opens, the comments form must open in a new record and vice versa.
I attach my database.
It opens on form "Process WIP Vessel Documentation". The comments form is at the bottom.
When you click on "General Information" control, the general Information form opens. The comments form is at the bottom. db2.mdb
Question by:Fritz Paul
    LVL 61

    Expert Comment

    Add the following code to the Open event of your main form:

         DoCmd.GoToRecord , , acNewRec

    Open in new window

    (You would use similar code in both forms - just specifying the appropriate subform name for each)
    LVL 61

    Accepted Solution

    So this would go in the open event of frmNewVesselGenInfo:
    Private Sub Form_Open(Cancel As Integer)
    '    ci_CenterIt Me, True, 3
         DoCmd.GoToRecord , , acNewRec
    End Sub

    Open in new window

    And this would go in the open event of frmProcWIPVessel:

    Private Sub Form_Open(Cancel As Integer)
        DoCmd.GoToRecord , , acNewRec
    End Sub

    Open in new window


    Author Closing Comment

    by:Fritz Paul
    Thanks a lot.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
    Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
    In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now