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!
mpimAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ares KurkluSoftware EngineerCommented:
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.
PatHartmanCommented:
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.
mpimAuthor Commented:
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...
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

mpimAuthor Commented:
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....
PatHartmanCommented:
You didn't post the code behind the subform.  Look for code that requeries the form or refreshes it or sets the Dirty property to True.  Those all as a SIDE Effect cause a record to be saved.

Looks to me as though you have experience programming in some other environment and are attempting to make Access work the way your other tool worked.  My advice is DON'T.  Access is a RAD tool and you will have the best success with it if you understand that and do things the "Access way".

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mpimAuthor Commented:
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!
PatHartmanCommented:
You're welcome.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.