Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Blank records added to subform

Status
Not open for further replies.

lexi0088

Technical User
Sep 7, 2004
49
I have a Form with a subform in it. As I enter data into the main form, new blank records get added to the subform. How do I prevent this from happening? I only want records to be added when I click into the subform.

The subform has totals in it that relate back to the main form. Would making this subform a opoup prevent this? And if so, how do I make it a pop up instead?


 
It should not happen by default. You must have something that is adding the record or modifying data in the subform causing it to be added. Perhaps one of the events on either the form or subform is doing it?
 
I have searched through all the code and could not find anything other than it setting the invoiceid
 
The invoiceid is in the main or sub form? It is set to what and which event set's it?
 
I went through all of the code on the main form and the subform and neither one of them have a reference to the other. The only thing linking them is the parent/child which is
Master Fields:INVOICEID (main form)
Child Fields:InvoiceID (subform)

I have to mention that I do have another subform on this form that has the exact same parent/child relationship and main setup which does not add new records until I click into it.

I have tried to use this code in the subform, but I have a combo box (Qtr) in the subform that will not work if this code is active.
Private Sub Form_BeforeInsert(Cancel As Integer)
If IsNull(Me.Qtr) Then
Me.Undo
Cancel = True
End If

End Sub

Any suggestions would be helpful. I really appreciate your help lameid.
 
Make another subform from scratch and plop it into the main form and see if it works the same way, or works properly.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Have you found a solution? I have this same problem - one main form, two subforms linked Parent/Child, and new blank records are being created once I tab into the second subform. I pull up that same set of forms in multiple circumstances and this only happens if the main form record is a new record. I'm about to just run a "delete all blank records" script every time I create a new main record, but that seems like messy programming...
Thanks for any help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top