473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Allow Duplicate Entries in a Combo Box

have a project in which I am entering Serial Numbers and Date codes into a Combo box. Serial numbers are all different. However, they could each have the same Date Code. Each Serial Number has a corresponding Date Code which I then write to a table using VBA. When I try to enter a duplicate date code, it automatically finds the duplicate and will not allow me to add it again to that combo box. How do I configure that combo box so I can enter the same date code multiple times?

I use a Command button to Add the data to both combo boxes which also adds the values to 2 listboxes.

Expand|Select|Wrap|Line Numbers
  1. ' 9-26-2008
  2. ' Modified: 1-19-2009 , Combined two buttons
  3. Dim frm As Form
  4. ' SN
  5. Dim ctl As Control
  6. Dim ctl1 As Control
  7. ' DC
  8. Dim ctl2 As Control
  9. Dim ctl3 As Control
  10.  
  11. On Error GoTo cmdAddSNErr
  12.  
  13. Set frm = Forms!frmPrimary_User_Interface '!frmPrimary_User_Interface.Form
  14. ' SN
  15. Set ctl = frm!lstSN
  16. Set ctl1 = frm!cboOrigSerialNum
  17. ' DC
  18. Set ctl2 = frm!lstDC
  19. Set ctl3 = frm!cboOrigDateCodes
  20.  
  21. 'intSNDCct = ctl.ListCount
  22. ' 2-14-2009
  23. ' Did the user enter the Quantity Rejected?
  24. If txtOrigQtyRej.Value <> "" Then
  25.     ' Yes
  26.     ' Did the user enter both a SN & DC
  27.     If ctl1.Value <> "" And ctl3.Value <> "" Then
  28.         ' Yes
  29.         ' Data entry for all of the serial numbers in this rejection notice
  30.         If intQtyRej <> ctl.ListCount And intQtyRej <> ctl2.ListCount Then             ' Make sure user doesn't add more serial numbers than Quantity Rejected
  31.  
  32.             'Me.lstSN.SetFocus
  33.             ' SN
  34.             ctl.AddItem ctl1.Value
  35.             ctl1.Value = ""
  36.  
  37.             'ctl1.Value = ""    ' Clear for next entry
  38.             ' DC
  39.  
  40.             ctl2.AddItem ctl3.Value
  41.  
  42.             ctl3.Value = ""                  ' Clear for next entry
  43.  
  44.             lblSNCount.Caption = "SN: " & ctl.ListCount & "/" & ctl2.ListCount & " of REJ: " & intQtyRej
  45.             intSNDCct = ctl.ListCount
  46.         Else                                                ' User exceeded Quantity Rejected
  47.  
  48.             MsgBox "Serial Numbers or Date Codes entered Exceeds Quantity Rejected value [" & intQtyRej & "]" & vbCrLf & "This last Serial Number or Date Code is ignored!", vbExclamation, "Serial Number(s) entry"
  49.             Exit Sub
  50.         End If
  51.     Else ' No
  52.             MsgBox "You must enter a Serial Number and a Date Code or enter '0' if none exists!" & vbCrLf & "Please make sure you enter both before attempting to add!", vbExclamation, "SN/DC entry: Missing Data"
  53.             cboOrigSerialNum.Value = ""
  54.             cboOrigDateCodes.Value = ""
  55.             cboOrigSerialNum.SetFocus
  56.             Exit Sub
  57.     End If
  58. Else ' No
  59.         MsgBox "You must enter the Quantity Rejected before you can add Serial Numbers and Date Codes!" & vbCrLf & "Please the Quantity Rejected!", vbExclamation, "SN/DC entry: Missing Data"
  60.         txtOrigQtyRej.SetFocus
  61.         Exit Sub
  62. End If
  63.  
  64. Set frm = Nothing
  65. ' SN
  66. Set ctl = Nothing
  67. Set ctl1 = Nothing
  68. ' DC
  69. Set ctl2 = Nothing
  70. Set ctl3 = Nothing
  71.  
  72. ExitcmdAddSN:
  73.     On Error GoTo 0
  74.     Exit Sub
  75.  
  76. cmdAddSNErr:
  77.     Select Case err.Number
  78.         Case Else
  79.             MsgBox err.Description & strErrSect, vbCritical, "Error " & err.Number & " in cmdAddSN"
  80.     End Select
  81.     Resume ExitcmdAddSN
Mar 16 '09 #1
4 4090
ChipR
1,287 Expert 1GB
What's the control source for your combo box?
Mar 16 '09 #2
NeoPa
32,556 Expert Mod 16PB
It sounds like you may have designed the table with a unique index on the date field.

If this isn't the case then please try to explain your problem more clearly with relevant error messages where appropriate.
Mar 17 '09 #3
I resolved the issue by creating a table to place those values in. We also went with just text boxes. If the user needs to view what they entered, I have a button that will load it into a ListView control. I found a great Function for populating a ListView Control. All you have to do is call it and send an SQL Statement to it. Real slick.

Thanks for your reply.
Mar 19 '09 #4
My project has many tables. I did not initially design the table structure. They use a Primary Key and Foreign Key. I split the database for Multi User usage.
Mar 19 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Gary Lundquest | last post by:
I have an application with MS Access 2000 as the front end and MySQL as the back end. All was well until I upgraded the MySQL (Linux) server. The Problem: I insert data into a cumulative table....
1
by: Gary Lundquest | last post by:
It appears to me that MySQL version 4 returns an error messge when doing an Insert that results in duplicate entries. Version 3 did NOT return an error - it dropped the duplicate entries and ran...
3
by: andreas.maurer1971 | last post by:
Hi all, since a few years I use the following statement to find duplicate entries in a table: SELECT t1.id, t2.id,... FROM table AS t1 INNER JOIN table AS t2 ON t1.field = t2.field WHERE...
5
by: Chris Lasher | last post by:
Hello Pythonistas! I'm looking for a way to duplicate entries in a symmetrical matrix that's composed of genetic distances. For example, suppose I have a matrix like the following: A B ...
10
by: Backwards | last post by:
Hello all, I'll start by explaining what my app does so not to confuss you when i ask my question. ☺ I have a VB.Net 2.0 app that starts a process (process.start ...) and passes a prameter...
5
by: Manish | last post by:
The topic is related to MySQL database. Suppose a table "address" contains the following records ------------------------------------------------------- | name | address | phone |...
4
by: trips | last post by:
iam reading a xml file and adding these value into combo box.The combo box now has duplicate values ,when displaying in combo box i should not display duplicate values .how do i do it?
2
by: fabiola1 | last post by:
I'm using Ms Access 2003. I have five tables called tblAllContract tblType tbInteranlContact tblSupplier tblManager The other four tables are linked to tblAllContracts with Id's.I have a...
4
by: ramdil | last post by:
Hi All I have table and it have around 90000 records.Its primary key is autonumber field and it has also have date column and name, then some other columns Now i have problem with the table,as my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.