VBA duplicated Data

Hi everyone,
  I have one question about duplicated value, for example, If we have continuous form when we input data more than once this value should add one and remove duplicate data how we can do it by VBA?
id       name      price   number

1        cola          20            2


thanks for any advice and solution
adamdaban dabanStudentAsked:
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.

Fabrice LambertFabrice LambertCommented:
Erm, I see that you have an "id" data.
Often this mean it is a primary key, wich prevent from entering duplicate records.

Plus manipulating continuous forms with VBA is fairly difficult, better leave that job to MS Access.
1
PatHartmanCommented:
your problem statement is unclear.  Whether the form is single, continuous, or DS is not relevant.  What is the set of unique columns?  Do you really want to add duplicate rows but just add an additional column with a sequence number?

Try to restate this using business terms.  Is a person doing the data entry?  where are the values coming from?  Why do you want to allow duplicates?  

The data fields you showed do not make sense to allow duplicates.  I don't know what ID is but the Name column should be unique.  That means there should be only a single price for each Name.  If you allowed multiple prices for a given product, how would you know which one to use?
1
adamdaban dabanStudentAuthor Commented:
Thanks for replying, my question is, for example, I want to add 1 Coca-Cola  and again add one more to the table I want only show one coca-cola with 2 quantity
item            number
coca-cola                         2

not like this

item            number
coca-cola                         1
coca-cola                         1
0
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

PatHartmanCommented:
Can you please tell us the business case and what you are counting.
0
adamdaban dabanStudentAuthor Commented:
I have the plan to make the small project for cashier system so I want  in my form when I add Items  if data is duplicated only increase  a number
0
PatHartmanCommented:
Trying to do this in a bound form would be very clunky and because you would have to cancel adding the current record and then update a different record, the user could easily be confused.

If you want to do this, change the DS subform to not allow adds and use unbound controls in the parent form to capture the Item and quantity.  When the user presses the complete button, your code will decide whether to add the record or update an existing one. The final step is to clear the unbound controls so they are ready for the next entry.
0

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
adamdaban dabanStudentAuthor Commented:
Thanks PatHartman, I will try to do it
0
PatHartmanCommented:
You're welcome.  Don't forget to close the question if this solution works for you.
0
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.