Link to home
Start Free TrialLog in
Avatar of Michael Paravicini
Michael ParaviciniFlag for Chile

asked on

Subform adds always two records instead of only one...

My subform always adds one record too many.. and not sure way. I always have two records although in the datasheet i only see one. As soon as I save the form a second record is created with zero values. Not sure what I'm doing wrong.. Thanks for any help!
Avatar of Ares Kurklu
Ares Kurklu
Flag of Australia image

You need to know where exactly the problem is, are there duplicate entries in the tables? in that case the program may be inserting twice
or there can be a problem with the display query it may be displaying it twice if there is something wrong with the join.
Avatar of PatHartman
The problem is caused by code behind your form.  You are dirtying a record and saving it and then the user is doing the same.  Please post all the code behind the form and we'll help you figure it out.
Avatar of Michael Paravicini


Hi Pat, I'm really at a loss. I can't find anything special.. I call the Subform from an existing subform as follows:

Call OpenFrame("frmResRates",  acNormal, "", "ResId=" & Me.RESID, IIf(Me.AllowEdits, acFormEdit, acFormReadOnly), acWindowNormal)

OpenFrame is a SUB used to openframes and validate user rights. In the Load() sub of the opened framed, I only have the following code:

Private Sub Form_Load()
' Show Form in correct Language
Call FormTranslate("frmResRates", "3", gUser.Lang)
Call SubFormTranslate("frmResRates", "ResRatesSubform", "4", Nz(gUser.Lang, "EN"))

' Check if read only
Call FormDisable("frmResRates", "ResRatesSubform", Me.AllowEdits)

' Fill in Default Data
Me.xGuestName = Forms!frmResGroup!frmResDetails!xGuestName
Me.RESID = Forms!frmResGroup!frmResDetails!RESID
End Sub

And the Save button only has a DoCmd.Close command. That's it... Any help would be tremendeously appreciated...
I just saw - the error only occurs if I click into the subform and change something. In this case it will add two rows while if I just save it immediately only one row gets saved....
Avatar of PatHartman
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Pat - you were absolutely right... I had a duplicate ID field which caused the problem.. Everything is working fine now.. Thank you for your help!
You're welcome.