467,927 Members | 1,954 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,927 developers. It's quick & easy.

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 !!!!!
Jul 24 '07 #1
  • viewed: 2906
Share:
7 Replies
dima69
Expert 100+
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
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. Me![SubFRM].Requery
  3. End Sub
Jul 24 '07 #2
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!AlertPersonnelSubFRM.Requery put me in infinite loop. (In on current event of AlertPersonnelSubFRM)

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
Jul 24 '07 #3
puppydogbuddy
Expert 1GB
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!AlertPersonnelSubFRM.Requery put me in infinite loop. (In on current event of AlertPersonnelSubFRM)

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!YourMainForm!YourSubformControl.Requery

Replace the above with the actual names used in your application.
Jul 24 '07 #4
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(checkbox).

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
Jul 24 '07 #5
puppydogbuddy
Expert 1GB
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(checkbox).

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..
Jul 24 '07 #6
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.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. Call AutoFillNewRecord(Forms!Alert)
  3.   [Forms]![Alert]![AlertPersonnelSubform].Requery
  4. 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
Jul 24 '07 #7
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.
Jul 24 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

By using this site, you agree to our Privacy Policy and Terms of Use.