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?
 
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
 
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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
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
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.