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!
Microsoft Access

Avatar of undefined
Last Comment
PatHartman

8/22/2022 - Mon
Ares Kurklu

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.
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.
ASKER
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...
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER
Michael Paravicini

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....
ASKER CERTIFIED SOLUTION
PatHartman

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
Michael Paravicini

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!
PatHartman

You're welcome.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.