473,765 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Duplicate Record issue with Training Database with Multiple tables & temporary tables

8 New Member
Hello, I'm hoping someone could help me out with a problem I've ran into while trying to create a training database. I'm just a beginner with Access and VBA so please take that into consideration.

The problem I'm having is the possibility of record duplication in my current database. I'm hoping maybe there's a way to set up a relationship or query/vba to prevent this.

I currently have a form (frmCE_AddAgent Training) which I use to select which line of business I want and then select a Team of agents that will be taking a new training class. This will then pull up a temporary table (tblAddTempB) which has a yes/no field so I can check those that will be able to attend. I can then close out of the pop-up temporary table and append those agents to my main table (tblCE_AgentTra ining).

Problem is I won't be the only person using this so there is a chance someone will add an agent that's already been added and then I'll have a duplicate record in my database.

I have three main tables:

tblHierarchy (this is from an ODBC and is updated daily so I don't add anything to this table)
-Agent_Name
-Agent_ID (Primary Key & the only field being copied to tblCE_AgentTrai ning)
-LineBusiness
-TeamLead
-Email
etc, about 50 fields on this one

tblCE_AgentTrai ning (Middle Man table if you will, gets data from Hierarchy and CEDetails)
-AGENT_ID
-Course_Number
-ClassID
-Registered
-Trainer
-Training_Locati on
-Completion_Date
-Date_Missed
-Date_Missed2
-Date_Missed3

tblCE_Details (list each training class details)
-Course_Number (Primary Key & the only field being copied to tblCE_AgentTrai ning)
-Course_Name
-Trainer
-StartDate
-EndDate
-LineBusinessSpe cific
-Duration
-Self_Paced

And my Temporary table which pulls in info from tblHierarchy and my form:

tblCE_AddTempB
-LeaveBlank (yes/no setup if someone is on vacation when during the time the class is offered)
-Missed (yes/no, I use this on a different part of form for after the fact and not used with append query)
-Agent_Name (So I'll know who I'm adding/skipping)
-TeamLead
-Course_Num (from my frmCE_AddAgentT raining)
-DateSelected (from my frmCE_AddAgentT raining)
-ClassID (from my frmCE_AddAgentT raining)
-Trainer (from my frmCE_AddAgentT raining)
-TrainingLocatio n (frmCE_AddAgent Training)


So each agent (AGENT_ID) can have multiple training (different Course_Number) and each Course_Number will have multiple agents. To add a team of agents into tblCE_AgentTrai ning I specify the class ID and course number /name from my frmCE_AddAgentT raining form and use a temporary table (tblCE_AddTempB ) to select the Agents that can attend and then append those AGENT_ID 's to the tblCE_AgentTrai ning.

So I'm thinking either my tables need work or I need better relationships or maybe some VBA that prior to appending when I close out the popup temporary table (tblCE_AddTempB ) and prior to saving will go through each record and make sure that AGENT_ID AND Course_Number do not match any existing AGENT_ID AND Course_Number on my final tblCE_AgentTrai ning. To me this seems like the best course at this point.

If I need to provide any additional info please let me know. I'd post a copy of my db but I'm getting ready to leave work and don't have time to wipe agents personal info right now.
Apr 18 '10 #1
3 2101
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
There a couple of ways to deal with this. The easiest is to make the primary key (or a seperate index) consisting of both Agent_ID and Class_ID. Since that must now be unique, you will not be able to add another record with the same combination of Agent and Class. If I recall correctly you will get an error message saying something like "Could not append records, would create duplicate fields in index"

2nd solution: In code, step through each record, and check whether it exists allready, and then append if it doesnt.
Apr 19 '10 #2
JMANTN
8 New Member
Thank you very much TheSmileyOne as I had my AGENT_ID and Course_Number's indexed but not correctly and that fixed my issue! I've been stuck on that for weeks.

Since I'm still learning I think I'll try and find out how to use VBA to step through each record to check against two or more fields as well sounds like a challenge for a beginner :)

Thanks again!
Apr 19 '10 #3
NeoPa
32,572 Recognized Expert Moderator MVP
Since I'm still learning I think I'll try and find out how to use VBA to step through each record to check against two or more fields as well sounds like a challenge for a beginner :)
Sounds like a very good idea :)

Welcome to Bytes!
Apr 20 '10 #4

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

Similar topics

8
9024
by: Kragen Sitaker | last post by:
ERROR: Cannot insert a duplicate key into unique index pg_class_relname_nsp_index We've been getting this error in our application every once in a while --- typically once an hour to once a day, although it varies over time. The daemon that gets the error exits and restarts a few seconds later. Usually it's fine then, but sometimes the error happens three or more times in a row. Occasionally, instead, we get "ERROR: Cannot insert a...
9
14586
by: Catherine Jo Morgan | last post by:
Can I set it up so that a certain combination of fields can't contain the same entries, on another record? e.g. a combination of FirstName/LastName/address? Or FirstName/LastName/phone? Or FirstName/LastName/email? Or is it possible to allow this but to throw up an alert message? Warning that this person is probably already in the database? TIA
5
3751
by: Sami | last post by:
Please bear with me, and if you answer this question, please do it step by step. I am new at Access, not at all sophisticated. I am using Office XP. This will need to be read in Access for Office 2000. I am creating a database to track student athletes. I have created the following tables. The table title is to the far left, with fields under each. The common field will be the StudentID field, which is their student number assigned...
4
3310
by: HLCruz via AccessMonster.com | last post by:
I am working with a database that has client information separated in to 4 related tables - tFolder, tAddress, tEmail, tPhone number. In addition there are related tables tGifts and tCalls. The database has roughly 22,000 records but should only have around 6,000. The remaining records are duplicates, but in many cases the correct data for one person is spread out between the duplicate records and related tables. I need to be able to...
9
11232
by: Tom_F | last post by:
To comp.databases.ms-access -- I just discovered, to my more than mild dismay, that some tables in my Microsoft Access 2003 database have duplicate numbers in the "AutoNumber" field. (Field Size is set to "Long Integer", and New Values is set to "Increment".) I know that an old version of the Jet database engine can cause this problem, but my version of msjet40.dll is 4.0.8618.0, which is supposedly bug-free in this respect. I am...
1
3154
by: bemadragon | last post by:
Hello, I have been struggling with this for a while. I am working on a rather simple database for calculation purposes in Access 2003. I have a table called Order that has a primary key field called OrderID. It is linked to a (sub)table called Parts (primary key: PartID: autonumber) and this one is linked to a (sub sub) table called SubParts (primary key: SubPartID: autonumber). The idea is that a Order can be filed for multiple parts and...
5
9002
by: jennwilson | last post by:
Using Access 2000 - I have a query that is suppose to return the records from table within specified time range and find matching data from another table . Table houses Clinician name, location and rate information Table houses Clinician name, location and number of units for each type of service rendered on each day. The two tables are connected by field Please see the code below SELECT .Clinician, .Location, .Date,...
1
2235
by: VinArt | last post by:
MS Acc 2003, XP Thank you in advance for any help. I have tables called "Makeup" and "Lines". Each makeup can have multiple lines. Goal is to create a new "makeup" with identical "lines" except with a new makeup id. I created a form Makeup Copy with Line Subform. In the main form there is ID (key field), Comments, Customer, Description plus an unbound field "NewMakeup". Each line of the subform has the fields "Makeup (primary...
25
20564
by: tekctrl | last post by:
Anyone: I have a simple MSAccess DB which was created from an old ASCII flatfile. It works fine except for something that just started happening. I'll enter info in a record, save the record, and try to move to another record and get an Access error "Record is too large". The record is only half filled, with many empty fields. If I remove the added data or delete some older data, then it saves ok and works fine again. Whenever I'm...
9
8223
by: weirdguy | last post by:
Hello all, I almost complete my mini project - Stock Inventory: To track goods/products enter and exit from warehouse or simply known as Stock Transaction (IN/OUT). This also include a Inventory Catalog which basically show all the products in the warehouse, each product details including category, description and most importantly quantity on hand. As mentioned above, I almost complete the database except the most important Form - New...
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10156
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9951
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9832
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8831
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5419
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.