When I create a new record on mainform, Subform ghosts data from previous record

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • FNA access
    New Member
    • Jun 2007
    • 36

    When I create a new record on mainform, Subform ghosts data from previous record

    I have a mainform that has a subform in the detail section and a subform in the footer section.(Both subforms are in datasheet view) When I click the navigation button to create a new record on the mainform. My subform in the detail section goes blank (this is what I want) but my subform in the footer section appears to have the data from the previous record displayed. When you click on the subform the data dissapears and displays blank. If I go back one record on the main form and return to the newly created record then the subform is blank. What I would like is to just have the subform show blank when I create the new main form record.

    I am unsure if it has anything to do with it, but I have some code that autofills my main form with data from the previous record, but the subform is not included in that code at all.

    If needed I can include a screen shot of what I mean if that will help.

    I don't know what I would have done without this forum, you guys ROCK !!!!!
  • dima69
    Recognized Expert New Member
    • Sep 2006
    • 181

    #2
    Originally posted by FNA access
    I have a mainform that has a subform in the detail section and a subform in the footer section.(Both subforms are in datasheet view) When I click the navigation button to create a new record on the mainform. My subform in the detail section goes blank (this is what I want) but my subform in the footer section appears to have the data from the previous record displayed. When you click on the subform the data dissapears and displays blank. If I go back one record on the main form and return to the newly created record then the subform is blank. What I would like is to just have the subform show blank when I create the new main form record.

    I am unsure if it has anything to do with it, but I have some code that autofills my main form with data from the previous record, but the subform is not included in that code at all.

    If needed I can include a screen shot of what I mean if that will help.

    I don't know what I would have done without this forum, you guys ROCK !!!!!

    Have you tried requerying that subform, something like
    Code:
    Private Sub Form_Current()
    Me![SubFRM].Requery
    End Sub

    Comment

    • FNA access
      New Member
      • Jun 2007
      • 36

      #3
      I tried this, but got error that it could not find the field ( I assume [subFRM] is meant as the name of my subform)

      I then tried to use Forms!AlertPers onnelSubFRM.Req uery put me in infinite loop. (In on current event of AlertPersonnelS ubFRM)

      I then tried in the on current event of my main form and i still see the display of the information associated to the main forms last record. Again the data is not actuallty there as when you click the subform it returns to an empty datasheetview.

      Any other suggestions are welcome

      Thanks

      Comment

      • puppydogbuddy
        Recognized Expert Top Contributor
        • May 2007
        • 1923

        #4
        Originally posted by FNA access
        I tried this, but got error that it could not find the field ( I assume [subFRM] is meant as the name of my subform)

        I then tried to use Forms!AlertPers onnelSubFRM.Req uery put me in infinite loop. (In on current event of AlertPersonnelS ubFRM)

        I then tried in the on current event of my main form and i still see the display of the information associated to the main forms last record. Again the data is not actuallty there as when you click the subform it returns to an empty datasheetview.

        Any other suggestions are welcome

        Thanks
        Your syntax for the requery appears to be incorrect. It should be:

        Forms!YourMainF orm!YourSubform Control.Requery

        Replace the above with the actual names used in your application.

        Comment

        • FNA access
          New Member
          • Jun 2007
          • 36

          #5
          I am unsure what is meant by subform control. My subform has two fields and is displayed in data sheet view. The two fields are Name (textfield) and Standby(checkbo x).

          Do you mean the name of the subform?

          Sorry for needing you to supersimplify, i assumed that control was like a textbox etc.

          Thanks,

          Chris

          Comment

          • puppydogbuddy
            Recognized Expert Top Contributor
            • May 2007
            • 1923

            #6
            Originally posted by FNA access
            I am unsure what is meant by subform control. My subform has two fields and is displayed in data sheet view. The two fields are Name (textfield) and Standby(checkbo x).

            Do you mean the name of the subform?

            Sorry for needing you to supersimplify, i assumed that control was like a textbox etc.

            Thanks,

            Chris
            The subform control is the name of the "container" for the subform on the Main form. The subform is the form inside the container. If you click on the border between the form and subform you will invoke the property sheet for the subform container that holds the subform.. The first property is the subform container control's name property, and the second property listed says Source Object. Source Object is the name of the subform inside the subform container. Frequently, the subform container and the subform itself have the same name,but not always>>>>>and you need the name of the container for your requery..

            Comment

            • FNA access
              New Member
              • Jun 2007
              • 36

              #7
              Thanks for the insight. I was unaware that the container even existed. I checked the name and it was different. I still have the subform display data from previous main form record.

              Code:
              Private Sub Form_Current()
              Call AutoFillNewRecord(Forms!Alert)
                [Forms]![Alert]![AlertPersonnelSubform].Requery
              End Sub
              I have taken some screens of the form that depicts what is happening, as well as what I would like to happen. How do I post the images, if you think they might help?

              Thanks

              Comment

              • FNA access
                New Member
                • Jun 2007
                • 36

                #8
                I got it too work, maybe not the most elegant way, but...

                All I did was in the current event of my main form I set the focus to my subform and then back to my main form and voila, no ghosted data.

                I don't understand why the ghosted data showed up in the first place, but it is gone now.

                Thanks to all who tried to help. It is greatly appreciated.

                Comment

                Working...