Modules & VBA :: Search In 2 Tables For A Duplicate

May 11, 2015

I have a database for my school that I'm creating to log books read by Pupils.

I have a Read table linked to both to a Pupil table and a Book table to say that the book has been read.

When I click on a Book in a listbox this adds a record to the Read table for the pupil - this code works great.

I want to check that the book is not already there but my code is not working.

Below the ID should come from the Pupil table and BookID from the Read table.

I think this is the problem....

The code stops on the Set*rs* = *db.OpenRecordset(mysql, *dbOpenSnapshot) with "Data type mismatch in criteria expression".

At this point mysql is "SELECT Count (ID) as Total from Read WHERE ID = '952' and BOOKID = '13';"

Option Compare Database
Private Sub List5_DblClick(Cancel As Integer)
Rem ------ 1st SECTION
Dim db As DAO.Database

[Code]......

View Replies


ADVERTISEMENT

Modules & VBA :: Code To Consolidate Two Tables And Remove Duplicate Entries

Oct 3, 2013

I have two tables in my Access database. Table 1 has three columns, First Name, Last Name and Phone Number. Table 2 has just 2 columns, First Name and Last Name. What I would like to do is write a VBA macro to consolidate Table 2 into Table 1 and insure any duplicate First Name-Last Name combination is removed.

Table1

Code:
F.Name L.Name Tel.N.
John Smith 12345
Larry Miller 12344
Tony Woods 12333

Table2

Code:
F.Name L.Name
Albert Black
Larry Miller
John Bush

Table1 Post-Macro

Code:
F.Name L.Name Tel.N.
John Smith 12345
Larry Miller 12344
Tony Woods 12333
Albert Black
John Bush

View 1 Replies View Related

How To Search For Duplicate Combinations

Apr 16, 2012

I need to be able to find duplicate combinations (or, I suppose, permutations). I have four columns in a table that all contain inter values. I want to be able to query so that I can see if there are more than one records that have, say, 12, 28, 5, 14 in columns 1, 2, 3, and 4, respectively.

View 5 Replies View Related

Arrgh, Search Form On Duplicate Names

Jun 18, 2006

Could anyone help me please?

I have incorporated a search form (previously posted on this forum) and it is not cooperating when there's a duplicate name on the listbox. There can be more than one, say, John Smith on the database. In order to differentiate between two John Smiths, I need to be able to see their date of birth, where they are and who assessed their work.

So, I type the name John Smith on the search box, list box shows me all the John Smiths in the database, but only shows the first John Smith's details on the relevant fields on the form. What I would like to do is to be able to click on each John Smith's name on the listbox and see their details on the relevant fields. Attached db is Access 2000.

Any help will be much appreciated. Thanks in advance :)

View 2 Replies View Related

Forms :: Search List Box Duplicate Records

Oct 15, 2014

I have used John Big Bootys Dynamic Search Form, however to search on the fields I want I have created a query which has mutiple tables and when I get a duplicate value in the search box, i.e. in Client, there are 2 client "A"s and when I click on one it automatically chooses both.From here I want to create a double click event to open that records in a form, but I can't if it defaults to both records.

View 1 Replies View Related

Modules & VBA :: Search Code Deactivates Navigation Buttons When Search Results Are Longer Than A Page

Jun 24, 2015

I have a form that has a subform on it. The main form shows a category of furniture and has custom navigation buttons and a search text box for asset numbers and command button that runs the search. The subform shows the asset numbers associated with that furniture category, sometimes there is only one asset number, in other cases there could be 60. There is a scroll bar to scroll through the asset numbers when there are too many to see in the initial window.

The buttons all work as they should except when I search for an asset number that is part of a category that has too many asset numbers to show in the main window. When this happens the "previous" and "next" navigation buttons do not take you to the previous or next record. All of the other buttons on the form work though - you can go to the first, or the last record, and you can search for a new asset.This is the code for the search:

Code:

Private Sub cmdAssetSearch_Click()
Dim rs As Object
If IsNull(Me.TextAsset) Or Me.TextAsset = "" Then
MsgBox "Please type in an asset number to search for.", vbOKOnly
Me.TextAsset.SetFocus

[code]....

I've also attached a picture of what I mean when I say there are more asset numbers than what the window shows.

View 6 Replies View Related

Using One Search Button To Search 4 Tables In A Database?

Mar 10, 2008

I have a database that uses four forms and each form has it's own table and each form has it's own search button to find a specific record within that table. I would like to use one search button that will look at all four tables and bring up the correct record when the request number is entered. Can I link all the tables to perform this or is code required? Can someone send me in the right direction for how to do this? Give me an example of code if it's required?
Thanks for any help I can get.

Laura Edmark

View 7 Replies View Related

Duplicate Tables In Relationships

Feb 9, 2005

I am creating a database that has 3 main tables. When i go to relationships it shows my three main tables and then it shows 2 more. The 2 extra tables are name inventory_table1 and stock_tbl1, these 2 tables were created by access for some unknow reason. some how it is creating a duplicate of my tables and they are not linked to anything in my database. How do i get rid of these tables so they will not show up in my relationship view.

View 7 Replies View Related

2 Tables - VIEW Duplicate Records

Feb 3, 2005

I have 2 tables that have the same structure and same column names - Table A and TAble B. If field1, field2, field3, field4, and field5 match - I want to see that duplicates exist.

How do I do it with 2 tables? I know the query wizard check for duplicates can do it in one table - but I need to compare the two.

thanks.

View 1 Replies View Related

Tables :: Duplicate Over Multiple Fields

Sep 21, 2012

I have a table that is going to track people. First Name, Last Name, and Date of Birth in three separate fields.I dont want to be able to add the same person in the table. How do i do this when the data is in separate fields.

View 9 Replies View Related

Tables :: Deleting Duplicate Records

Sep 11, 2013

i have a data base with a primary key but some records have been added from a excel data base and now the data base has duplicate records with different primary keys. I do a Query looking for duplicate records based on a field not the the primary key. There are 315 out of 22000. I can sort the table and then manually delete the dups. The Query does not allow deleting records so finding the culprits in the full Data base is time consuming. How can i delete the duplicate records using a query? Is this function available hidden someplace in the guts of Access? Seems like this would be a frequent problem. The Microsoft forum addresses this problem and the only viable solution is the manual method, when they get to the Query method it looks like they just forgot what the subject was and tell you how to delete one record if you know what the criteria is. If two non Key fields are Identical then i want to delete one of the records.

View 3 Replies View Related

Cannot Allow Duplicate Records In 2 Tables Based On 2 Criteria

Sep 26, 2005

Dear all,

I would like to seek your help on this problem.

I would like to do a search for my records based on 2 different criterias. If found, the function should just return a boolean value so that I can act further based on the boolean value.

The reason I'm doing this is that I have 2 similar tables that contains EventID and AttendeeID and these 2 tables cannot have the same EventID and AttendeeID. So before I can allow a record to be inserted in the 1st table, it must check that there is no record in the 2nd table that has the same EventID and AttendeID. If there is, then i cannot allow the record to be inserted in the 1st table.

The same thing applies when I want to insert a record in the 2nd table. It must now check the first table.

Recordset.find seems to be only catering to 1 criteria, not 2.

Pls help. Codes are most welcome too.

View 3 Replies View Related

Comparing 2 Tables To Find Duplicate Values

May 9, 2006

Hey all

Im rather new to access but have to use it at work. Ive been asked to see if there is a way to delete duplicate records from a table.

Now, I have 2 tables. The 1st table (tbl_list) contains records of various customer details. This list is old.

The second table (tbl_new_list) contains new customer details.

We have found that we have the same customer details in tbl_new_list that are in the old table.

Im looking for a way to compare these 2 tables so that the values in tbl_list are not in tbl_new_list.

I have tried numerous methods using append queries but nothing seems to work.

Thanks in advance people

P.S the data will be compared through a telephone number.

View 1 Replies View Related

Tables :: Remove Duplicate Table In Relationships

Feb 10, 2014

I am using Access 2007, and I mistakenly created a duplicate table in Relationships. And, I have not been able to removed it or delete it.

View 6 Replies View Related

Tables :: SKU Generator - Duplicate Record Prevention

Oct 29, 2012

I am working on a SKU generator and I need to prevent duplicate SKUs, but each SKU is made from several different fields. i.e. Brand, Color, Design, etc.

I was wondering if Concatenating would be OK for this situation. I know concatenating usually results in redundant data and I try to avoid that.

I would like to just index (no duplicates) the entire record... is this possible? I can't just set that attribute to each field because there will be many duplicates on a per field basis. i.e. Brand will be duplicated every time I use the same vendor for a different shirt.

I can't just go back and address duplicates once they occur. I need to prevent them from occurring in the first place.

View 2 Replies View Related

Tables :: Removing Duplicate Records From One Table

Feb 18, 2014

I have a table with at least 13.000.000 records. There are many duplicates records... For example

ID Name Family mobile car number chassis Register_Year
1 Roy Jalbout 9999 123456/G ASF4546 2005
2 Roy Jalbout 9999 854658/G GRK554JFJD 2009
3 Tony Elishah 1234 854658/G GRK554JFJD 2012
4 Sam Markos 5478 854658/G GRK554JFJD 2014
5 Roy Jalbout 9999 123456/G ASF4546 2005

As you can see ID Number 2,3,4 have the same car but every one bought from another so it's not duplicates

The duplicates here is the ID's number 1,5. So how to remove the duplicates. I remember you i have at least 13.000.000 records. I try to make a query to find duplicates then i make a copy of the original table and than i should make a primary key then append the data from the original table to the copy table, but here i have more than one criteria

When I made a query to find duplicates the result was 680.000 records and every one have a minimum 2 duplicates an maximum 4 duplicates so it's about 2.500.000 duplicates records at least....

View 5 Replies View Related

Tables :: Prohibiting Duplicate Data In A Table

Nov 12, 2012

I'm having some issues with stopping duplicate entries in a table and have tried a copule different ways with no avail.

In one table in particular, I have a table holding employees as followed;

EmployeeID: PK
FirstName
MInitial
LastName
Company:FK
DepartmentFK

What I am trying to do is stop the ability to duplicating records over a series of fields (FirstName, MInitial, LastName, Company)rather than just one specific field.

I attempted to index the table as followed;

EmployeeID: PK/Unique
FirstName: Unique
MInitial: Unique
LastName: Unique
Company: Unique

The problem with this is it wont allow me to enter more than one person with the same first, middle, or last name or company.

I tried "DCount" Code in a form with no luck, that code reads as followed:

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If DCount("*", "tblEmployees", "[firstname]=" & Chr(34) & Me!firstname & Chr(34) & _
" And [MInitial]=" & Chr(34) & Me!MInitial & Chr(34) & _
" And [LastName]=" & Chr(34) & Me!LastName & "#") > 0 Then
Msgbox "Person already exists."
Cancel = True
End If
End Sub

Note: this code was initially used on a different database I was working on that accounted for an individuals First Name, Last Name, and Date of Birth which worked great. I am just trying to apply that similar concept to this new database with first name, middle initial, last name, and company; which will be a foreign key.

View 10 Replies View Related

Tables :: Duplicate Results In Count Queries?

Feb 18, 2013

I have a table with a field 'FName'. I have run a query to count the number of each Name in this field. However, as well as having a blank field with 9129 results (which was expected) but another with 24 results that appears to be completely blank as well. There are another couple of incidences were results in 'FName' are appearing twice.

how to identify what is causing this duplication?

View 5 Replies View Related

Tables :: Training Database With No Duplicate Data

Aug 3, 2013

I am preparing a "simple" training database. I want to do this smartly and not duplicate data.

My first table is the list of employees and their information. I have set a primary key (PK) up for each employee.

My second table is a list of training courses - title, description, start/stop time, credits, ... Each of these courses has a unique number (PK).

It's the final database table that is driving me nuts. I want it to show whether a n employee has taken/will take/not planning to take a course. My idea is to have a status field and then wanted to link that with a student number and a course number from the other tables.

In the past I would just have put common data fields StudentName from one table and CourseName from the other into the final database tables as a means of linking them. But I thought/read it's better to use a PK instead. Well when I make the third table up I get all of this Type Mismatch errors.

View 6 Replies View Related

How To Prevent Duplicate Profiles With Multiple Tables

Oct 30, 2014

I am creating essentially a contact database; however, I want to be able to upload new groups into the database from time to time. Some people in the groups may already be listed somewhere else. If I am using an ID number to identify each separate profile; how do I prevent a duplicate profile entry? Will I have to manually check each one? Also if I use the auto-number function, how do I tell access to create a new set of numbers that are different from ones previously assigned? I anticipate about 30 separate groups adding up to around 5,000 names. I don't really care to check that many manually.

View 1 Replies View Related

Tables :: Detect / Delete Duplicate Records In A Table

Apr 22, 2014

I'm wondering if it's possible to create a Query / Macro / VBA or whatever works, to detect the duplicate records in a table and delete them with the push of a command button. Or, even to do this automatically when the database opens using an AutoExec macro or something ?. I'd like for one copy of each record to be left intact in the table.

View 8 Replies View Related

Tables :: Change Duplicate Values Error Message

Aug 14, 2013

How to control the below message to something like this through VBA:

"The Job: " & JobNumber & " already exists in the table." or to open an alternate form where they can make the change. Allowing duplicates is not appropriate for what I am trying to accomplish. I just want a friendly way of rerouting a user to understandable answer.

instead of this:

"The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again."

View 2 Replies View Related

Tables :: Unique Identifier - Increment For Duplicate Records

Jul 10, 2014

I'm currently in the process of doing a an overhaul of the database including a table, some odd 17,500 records long.

What I need to do is to create a unique identifier from the existing part number, almost like an autonumber, but it only increments when there are duplicates. What I mean is that there would be for example, there would be five records of say, part 000135.

What I'm trying to get at is, how I would have to code to grab the existing part numbers (all formatted to be 6 digits), add an extra 2 digits to be its unique identifier, and then save it all to a Unique Identifier column, that I created.

An example of what I want is say, I have part numbers 000135 and 000136. The numbers would go up from 000135-01, 000135-02, 000135-03, 000136-01, 000136-02.... The dash is not as important as implementing the 2 digit unique identifier.

View 5 Replies View Related

Tables :: Consolidating Duplicate Values Without Losing Other Information

Jun 11, 2013

I've got a table which lists accounts with an associated charge. If the account has multiple charges, then the account appears multiple times, for each charge. I'd like to consolidate the duplicates without losing each charge that is associated with the account.

View 4 Replies View Related

Tables :: Unique Multicolumn - Avoid Duplicate Records

May 28, 2014

I have 3 tables

tbl1 :
NameID
Name

tbl2 :
CatID
Category

tbl3 :
ProdID
CatID
NameID
Remarks

How can I avoid duplicate records in tbl3? Since remarks can be Null? product is later used in tblInventory...

View 1 Replies View Related

Modules & VBA :: Code To Take To A Duplicate Record

Aug 13, 2013

I have a form based on a query and have written code to display a msgbox if a duplicate entry is inputted in the NHS_Number field in the form. I have also added code "me.undo" to clear the form so that it is not saved. I am looking for a piece of code that will display the duplicate record. Here is my code thus far:

Private Sub NHs_Number_BeforeUpdate(Cancel As Integer)
Dim dbs As Database
Dim rst As DAO.Recordset
Dim x As Integer

[Code]....

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved