« 6TH POPE Home | Email msg. | Reply to msg. | Post new | Board info. Previous | Home | Next

Re: Access Question for Zimbler

By: Zimbler0 in 6TH POPE | Recommend this post (0)
Mon, 23 May 22 2:53 AM | 29 view(s)
Boardmark this board | 6th Edition Pope Board
Msg. 32179 of 60008
(This msg. is a reply to 32175 by Decomposed)

Jump:
Jump to board:
Jump to msg. #

I believe the way I found duplicates was with a query.

This site has some instructions on how to create a query to look for duplicates . . .

http://www.wikihow.com/Find-Duplicates-Easily-in-Microsoft-Access

I think you can write a query such that your code feeds a parameter into it - the title you are entering and want to see if it is already in there. There is a field titled 'criteria' in the query design window and in there you can ask is the new title already in the database.

Or this . .

http://www.everythingaccess.com/tutorials.asp?ID=Finding-duplicate-records-in-a-table
>>>
Finding Duplicates in an imported DBF

Importing a DBF file into Access is no problem, but if the DBF has been in service for any period, you might discover duplicates in the field which is supposed to be the primary key for referential lookups. If any record has a duplicate in this field, it can be very frustrating trying to make the field a Primary Key in Access, especially if there are thousands of records to search through. So how do you locate the duplicates?

If you know SQL or stumble across the Find Duplicates Query Wizard, the solution may be obvious. This Wizard actually uses different methods for different needs. The discussion here covers only one method, and works with version 1 (which doesn't have the Wizard).

Create a new query, and add the table you are working on.
Click the Totals button on the toolbar (upper case Sigma). A "Total" row will be added to the grid.
Drag your field into the grid, and in the Total row, select Group By.
Drag the same field into the grid a second time. For this second instance, select Count for the Total row, and enter ">1" in the Criteria row.
Run the query, to view the contents of offending records, and the number of duplicates you need to locate.
>>>

Or this :

http://bytes.com/topic/access/answers/673876-how-check-duplicate-records
>>>
Try this (substitue your names). DAO reference required.
Expand|Select|Wrap|Line Numbers

Private Sub txtNewData_BeforeUpdate(Cancel As Integer)
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("MyDataTable", dbOpenSnapshot)
rs.FindFirst "txtDataField = """ & Me![txtNewData] & """"
If Not rs.NoMatch Then
Cancel = True
MsgBox "Duplicate Value"
End If
End Sub
>>>

(I've forgotten most of the VBA I once learned. . . .)

I think I told you I retired the other year? I'm sure I have copies of my old Access databases within which I know I had done some pretty 'strange' stuff . . . But at work we were using Access 2007 and now I'm reduced to Access 2000. (For my 'portfolio database'.) Should I see if I can set up a machine that can open and peruse my old databases?

Zim.




Avatar

Mad Poet Strikes Again.


- - - - -
View Replies (1) »



» You can also:
- - - - -
The above is a reply to the following message:
Access Question for Zimbler
By: Decomposed
in 6TH POPE
Mon, 23 May 22 1:56 AM
Msg. 32175 of 60008

Zimbler0:

Re: “How to check for a duplicate?”
I'd like my database to tell me each time I enter a new book title or modify an existing one how many books with that name are already in the table. If the answer is 'none,' I wouldn't want it to say anything. I don't want it preventing entry of a duplicate... just informing me with MsgBox.

  • The form is frmMedia.
  • The table is tblMedia.
  • The form has a field named Title.
  • The table has a field named Title.

Do you know how? I've been trying with DCount, like this:


Private Sub Title_lostFocus()
Dim x As Integer
  x = DupTitleCount()
  MsgBox (x)
End Sub

Public Function DupTitleCount() As Integer
  DupTitleCount = DCount("[Title]", "tblMedia", "[tblMedia].[Title] = [frmMedia].[Title]")
End Function






« 6TH POPE Home | Email msg. | Reply to msg. | Post new | Board info. Previous | Home | Next