TheSecretaryJen
New Member
- Joined
- Jul 3, 2015
- Messages
- 18
Hi all,
I have a userform I have built to input training records for my company. I want to prevent users from accidentally putting in a duplicate record.
The record table is called "TrainingRecords." It has several columns of data, but I only want to check four columns: "Employee Name" (Column 1), "Start Date" (Column 10), "End Date" (Column 11), and "Concatenated Training" (Column 16).
Here is how the form works: the user inputs the start date and end date in textboxes on the userform, called "DateInputStart" and "DateInputEnd" respectively. The Concatenated Training value goes into a textbox called "Training".
Here is where it gets seriously complicated: the user can put in up to fifty names at once. I have fifty labels that are set as invisible on the userform when it initializes. Each of these labels is called "Name1," "Name2," etc., all the way up to "Name50." When the user wants to input a name, they choose from a drop-down list in a combobox and click a command button. This command button increases the Name Count number (in an invisible textbox) by one, and then takes the resulting number and chooses the label accordingly. This label then becomes visible and shows that name as a caption. I.e., when a user chooses his/her first name and clicks the button, the count increases from 0 to 1, and then the code knows to put that name into the "Name1" label caption. It does this up to 50 times, and then if they try to add another name, it informs them that they can't.
SO. This duplicate-check code has to take each one of the used label captions, find those names in Column 1 of my table, then check the adjacent cells in Columns 10, 11 and 16 to see if they match the values in the three aforementioned textboxes. If a complete match is found, I want a message box to pop up and tell the user that they are trying to enter a duplicate record.
I have tried multiple ways to solve this, and I am now totally stumped to the point that I don't even have example code to show you guys. I'm also afraid that having to check up to fifty names is going to seriously slow down the code. Any thoughts or advice?
I have a userform I have built to input training records for my company. I want to prevent users from accidentally putting in a duplicate record.
The record table is called "TrainingRecords." It has several columns of data, but I only want to check four columns: "Employee Name" (Column 1), "Start Date" (Column 10), "End Date" (Column 11), and "Concatenated Training" (Column 16).
Here is how the form works: the user inputs the start date and end date in textboxes on the userform, called "DateInputStart" and "DateInputEnd" respectively. The Concatenated Training value goes into a textbox called "Training".
Here is where it gets seriously complicated: the user can put in up to fifty names at once. I have fifty labels that are set as invisible on the userform when it initializes. Each of these labels is called "Name1," "Name2," etc., all the way up to "Name50." When the user wants to input a name, they choose from a drop-down list in a combobox and click a command button. This command button increases the Name Count number (in an invisible textbox) by one, and then takes the resulting number and chooses the label accordingly. This label then becomes visible and shows that name as a caption. I.e., when a user chooses his/her first name and clicks the button, the count increases from 0 to 1, and then the code knows to put that name into the "Name1" label caption. It does this up to 50 times, and then if they try to add another name, it informs them that they can't.
SO. This duplicate-check code has to take each one of the used label captions, find those names in Column 1 of my table, then check the adjacent cells in Columns 10, 11 and 16 to see if they match the values in the three aforementioned textboxes. If a complete match is found, I want a message box to pop up and tell the user that they are trying to enter a duplicate record.
I have tried multiple ways to solve this, and I am now totally stumped to the point that I don't even have example code to show you guys. I'm also afraid that having to check up to fifty names is going to seriously slow down the code. Any thoughts or advice?