A
Amy Adams via AccessMonster.com
I have a complicated situation that I will do my best to explain. Been
trying to puzzle this one our for a couple days now.
I have 4 tables
1. Physicians - Primary Key "UPIN"
2. Groups - Primary Key "Group ID"
3. Plans - Primary Key "PlanID"
4. PhysicianPlan - Combines all 3 primary keys in large table UPIN,
PlanID, and GroupID this table has over 34,000 records
The following is an example of PhysicianPlan
UPIN PlanID GroupID
1 2 3
1 2 4
1 2 5
1 2 6
Etc
If a new physican needs to be added to the database it is done through a
form. This form contains a command button that runs an append query.
Append query add all necessary plans and groups to new physician. What has
been happening occasionally is that a user appends a physician that does
not need appending and duplicate records are added to my PhysicianPlan table
Example:
UPIN PlanID GroupID
1 2 3
1 2 4
1 2 5
1 2 6
1 2 3
1 2 4
1 2 5
1 2 6
How can I stop the duplicates? Can I give my user a warning that says
"This physician is already updated with Plans and Groups. Proceed Anyway?"
and give thme a choice.
Here are the 3 things I have thought to try:
1. I have thought about using Dlookup and was looking at the previous post
titled "3 Fields together unique/no duplicates" where code looked like
this:
Private Sub Form_BeforeUpdate(Cancel as Integer)
Dim vFound As Variant
vFound = DLookUp("PersonID", "your-table-name", "[FName] = """ & _
Me!txtFName & """ AND LName = """ & Me!txtLName & _
""" AND PostCode = '" & Me!txtPostCode & "'")
If Not IsNull(vFound) Then
MsgBox "This person's name already exists. Proceed anyway?", _
vbYesNo)
If iAns = vbNo Then Cancel = True
End If
End Sub
But cannot seem to get it to work for me.
2. I also, looked into trying to add critera to my append query but cannot
figure that out.
3. Finally I looked into adding something into the condition statement of
my macro that runs the append query. to stop macro if criteria already
exists.
Any suggestions?
trying to puzzle this one our for a couple days now.
I have 4 tables
1. Physicians - Primary Key "UPIN"
2. Groups - Primary Key "Group ID"
3. Plans - Primary Key "PlanID"
4. PhysicianPlan - Combines all 3 primary keys in large table UPIN,
PlanID, and GroupID this table has over 34,000 records
The following is an example of PhysicianPlan
UPIN PlanID GroupID
1 2 3
1 2 4
1 2 5
1 2 6
Etc
If a new physican needs to be added to the database it is done through a
form. This form contains a command button that runs an append query.
Append query add all necessary plans and groups to new physician. What has
been happening occasionally is that a user appends a physician that does
not need appending and duplicate records are added to my PhysicianPlan table
Example:
UPIN PlanID GroupID
1 2 3
1 2 4
1 2 5
1 2 6
1 2 3
1 2 4
1 2 5
1 2 6
How can I stop the duplicates? Can I give my user a warning that says
"This physician is already updated with Plans and Groups. Proceed Anyway?"
and give thme a choice.
Here are the 3 things I have thought to try:
1. I have thought about using Dlookup and was looking at the previous post
titled "3 Fields together unique/no duplicates" where code looked like
this:
Private Sub Form_BeforeUpdate(Cancel as Integer)
Dim vFound As Variant
vFound = DLookUp("PersonID", "your-table-name", "[FName] = """ & _
Me!txtFName & """ AND LName = """ & Me!txtLName & _
""" AND PostCode = '" & Me!txtPostCode & "'")
If Not IsNull(vFound) Then
MsgBox "This person's name already exists. Proceed anyway?", _
vbYesNo)
If iAns = vbNo Then Cancel = True
End If
End Sub
But cannot seem to get it to work for me.
2. I also, looked into trying to add critera to my append query but cannot
figure that out.
3. Finally I looked into adding something into the condition statement of
my macro that runs the append query. to stop macro if criteria already
exists.
Any suggestions?