473,665 Members | 2,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Duplicate in particular row

31 New Member
Iam using the below code to search the duplicate records in Ms Excel before uploading to Ms access.

It is working fine but i want the msgbox to display that there is a duplicate record in perticular row.

Kindly help how to mention the same

Ananth
------------------------------------
Expand|Select|Wrap|Line Numbers
  1. Set rst = DB.OpenRecordset("Claim_Status", dbOpenDynaset)
  2.  
  3. myRow = ActiveCell.Row
  4.  
  5. If rst.RecordCount <> 0 Then
  6. rst.FindFirst "StrInward_No = '" & RANGE("A2") & "'"
  7. If Not rst.NoMatch Then
  8.  
  9. R = 2
  10. Do While Len(RANGE("A" & R).Formula) > 0
  11. R = R + 1 ' next row
  12. Loop
  13.  
  14. MsgBox "Duplicate records found in" & myRow
  15.  
  16. ActiveWorkbook.Close
  17. rst.Close
  18.  
  19. Set rst = Nothing
  20. Set DB = Nothing
  21.  
  22. Exit Sub
  23. End If
  24. End If
Sep 1 '08 #1
3 1567
MikeTheBike
639 Recognized Expert Contributor
Hi

There seems to be an anomily in the code as there is no way you can find a duplicate as it stands. Without knowing anything about what you are trying to do, I suggest this, pehaps, may be what you want??
Expand|Select|Wrap|Line Numbers
  1. Set rst = Db.OpenRecordset("Claim_Status", dbOpenDynaset)
  2.  
  3. myrow = 0 'set row value
  4.  
  5. If rst.RecordCount <> 0 Then
  6.     rst.FindFirst "StrInward_No = '" & Range("A2") & "'"
  7.     If Not rst.NoMatch Then
  8.  
  9.         R = 3 ' start on next line to original search !!
  10.         Do While Len(Range("A" & R).Formula) > 0
  11.             If Range("A" & R) = rst("StrInward_No") Then 'compare cell with record found ??
  12.                 myrow = R 'if found set row value
  13.                 Exit Do ' and exit do (job done)!
  14.             End If
  15.             R = R + 1  'next row
  16.         Loop
  17.  
  18.         If myrow <> 0 Then MsgBox "Duplicate records found in ROW " & R ' ouput row if found.
  19.  
  20.         ActiveWorkbook.Close
  21.         rst.Close
  22.  
  23.         Set rst = Nothing
  24.         Set Db = Nothing
  25.  
  26.         Exit Sub
  27.     End If
  28.  
  29.     Set rst = Nothing ' ??
  30.     Set Db = Nothing ' ??
  31. End If
HTH


MTB
Sep 1 '08 #2
Tempalli
31 New Member
Hi

There seems to be an anomily in the code as there is no way you can find a duplicate as it stands. Without knowing anything about what you are trying to do, I suggest this, pehaps, may be what you want??
Expand|Select|Wrap|Line Numbers
  1. Set rst = Db.OpenRecordset("Claim_Status", dbOpenDynaset)
  2.  
  3. myrow = 0 'set row value
  4.  
  5. If rst.RecordCount <> 0 Then
  6.     rst.FindFirst "StrInward_No = '" & Range("A2") & "'"
  7.     If Not rst.NoMatch Then
  8.  
  9.         R = 3 ' start on next line to original search !!
  10.         Do While Len(Range("A" & R).Formula) > 0
  11.             If Range("A" & R) = rst("StrInward_No") Then 'compare cell with record found ??
  12.                 myrow = R 'if found set row value
  13.                 Exit Do ' and exit do (job done)!
  14.             End If
  15.             R = R + 1  'next row
  16.         Loop
  17.  
  18.         If myrow <> 0 Then MsgBox "Duplicate records found in ROW " & R ' ouput row if found.
  19.  
  20.         ActiveWorkbook.Close
  21.         rst.Close
  22.  
  23.         Set rst = Nothing
  24.         Set Db = Nothing
  25.  
  26.         Exit Sub
  27.     End If
  28.  
  29.     Set rst = Nothing ' ??
  30.     Set Db = Nothing ' ??
  31. End If
HTH


MTB
I am a beginer in MS Access. As per ur code as below it is showing blank row as duplicate. i am uploading a excel sheet contains StrInward_No's as 1 2 3 4 in 4rows but the code is showing as row 5 contains duplicate. kindly help.

Set rst = DB.OpenRecordse t("Claim_Status ", dbOpenDynaset)
myrow = ActiveCell.Row

If rst.RecordCount <> 0 Then
R = 2 ' start on next line to original search !!
Do While Len(RANGE("A" & R).Formula) > 0
If RANGE("A" & R) = rst("StrInward_ No") Then 'compare cell with record found ??
myrow = R 'if found set row value
Exit Do ' and exit do (job done)!
End If
R = R + 1 'next row
Loop

If myrow <> 0 Then MsgBox "Duplicate records found in ROW " & R ' ouput row if found.

'MsgBox "Duplicate records found in" & myrow

ActiveWorkbook. Close
rst.Close

Set rst = Nothing
Set DB = Nothing

Exit Sub
End If
Sep 2 '08 #3
MikeTheBike
639 Recognized Expert Contributor
I am a beginer in MS Access. As per ur code as below it is showing blank row as duplicate. i am uploading a excel sheet contains StrInward_No's as 1 2 3 4 in 4rows but the code is showing as row 5 contains duplicate. kindly help.

Set rst = DB.OpenRecordse t("Claim_Status ", dbOpenDynaset)
myrow = ActiveCell.Row

If rst.RecordCount <> 0 Then
R = 2 ' start on next line to original search !!
Do While Len(RANGE("A" & R).Formula) > 0
If RANGE("A" & R) = rst("StrInward_ No") Then 'compare cell with record found ??
myrow = R 'if found set row value
Exit Do ' and exit do (job done)!
End If
R = R + 1 'next row
Loop

If myrow <> 0 Then MsgBox "Duplicate records found in ROW " & R ' ouput row if found.

'MsgBox "Duplicate records found in" & myrow

ActiveWorkbook. Close
rst.Close

Set rst = Nothing
Set DB = Nothing

Exit Sub
End If
Hi

Small floor in my code this

If myrow <> 0 Then MsgBox "Duplicate records found in ROW " & R

should have been this

If myrow <> 0 Then MsgBox "Duplicate records found in ROW " & myrow

That is the penalty of air code !

But apart from that

1) I cannot down load files (IT policy prevents this).

2) You seem to have missed the lines

rst.FindFirst "StrInward_ No = '" & RANGE("A1") & "'"
If not rst.NoMatch Then


End If

etc

3) lines with 1, 2, 3, 4 in do not duplicate any data ??

4) I still think you should initialise myrow = 0 at the start of the code (what is the Active Cell at this time) !!??

BTW if the field StrInward_No is numeric then this

rst.FindFirst "StrInward_ No = '" & RANGE("A1") & "'"

should be

rst.FindFirst "StrInward_ No = " & RANGE("A1")


MTB
Sep 2 '08 #4

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

Similar topics

44
4032
by: Xah Lee | last post by:
here's a large exercise that uses what we built before. suppose you have tens of thousands of files in various directories. Some of these files are identical, but you don't know which ones are identical with which. Write a program that prints out which file are redundant copies. Here's the spec. -------------------------- The program is to be used on the command line. Its arguments are one or
5
2380
by: Steve B. | last post by:
A particular column in my Access DB table, and the associated datagrid, cannot have duplicate string entries. I've selected "Yes (no duplicates)" for the Indexed Field Property of this column in the Access table. When I call update(), the DB gets updated but throws an exception saying, in affect, that I'm trying to change the key. This column is not the key. How do I handle this? How do I stop the ex.message being thrown? I guess I...
2
1249
by: Brad Allison | last post by:
I have created a short routine to read certain data from an AS400 and put it into a small table stored in Access (I know not the best data store, but it is what we have for now). Anyway, some of this data coming from the AS400 is duplicating a unique data column and with the try...catch I get errored out and the sub exits. Is there a way if a certain error occurs to disregard the added row to the table and continue the sub instead of...
4
1777
by: skalra3 | last post by:
Hi, I just want to know that is there any way by sql that we can extract duplicate records from the name field in a particular table suppose table1 and put it in other tables?
0
1561
by: UT-BadBoy | last post by:
Hi, I've been working with ASP.NET for about a year so I'm still considering myself to be somewhat of a novice in this field. I am receiving this particualr error when trying to hit a webservice from an IE browser: The namespace, , is a duplicate. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more
0
2371
by: Narendra Gc | last post by:
Hi... I am looking after a lan . I am i am not able to access one particular system , by another one particular system. But from these computers i can access all other systems in my lan and vice- versa.only the communication between these two computers is affected. Error is " A duplicate name exists on the network " I searched in google i got the following solutions. 1)A. The "Duplicate name exists" error indicates the...
4
2888
by: ramdil | last post by:
Hi All I have table and it have around 90000 records.Its primary key is autonumber field and it has also have date column and name, then some other columns Now i have problem with the table,as my table contains duplicate entries for a particular date.How can i delete the duplicate entries from the table for that particular column,Now i am doing manually with name column as it will be unique for that date.Can any one help me giving the query...
4
4193
by: Thomas Arthur Seidel | last post by:
Hello to all, I have a small or big problem with a customer data base, where during a change of system we might have created duplicate records. This should be easy to find, you might think, but, we are talking about roughly 10000 records or less in a total volume of 1 MIO records or more. I have considered a strategy: The station ID and a field with something like a sequence number are supposed to be unique during that period. The...
4
5436
by: ravir81 | last post by:
Hi, I am currently working on excel validation using Perl. I am new to Excel validation but not for Perl. I have a question regarding one of the validation. Could anyone please tell me how to get the number of duplicate rows based on a particular cell value of each these duplicate rows. I mean all the cell values of a row will not be duplicated but a individual columns cell value will be duplicated and I need to create a separate excel with...
0
8438
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
8863
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...
1
8549
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
8636
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
7376
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...
1
6187
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4356
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2765
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.