473,508 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to find duplicate records in access database using vb6

1 New Member
pls help me to find the duplicate record in vb6 i'm using access 2007. and my code is..
Expand|Select|Wrap|Line Numbers
  1. If (rs2.Fields(0) = copnme_txt.Text) Then
  2. reset
  3. Else
  4. rs2.AddNew
  5. rs2.Fields(0) = copnme_txt.Text
  6. rs2.Update
  7. reset
  8. End If
  9.  
reset is the function to reset all the textbox. In the code if condition is checking but it is strucking in
rs2.update. i've made the column as primary key. so primary key is arising.. pls it is very pls help me.. thanks in advance..
Jun 21 '13 #1
2 3668
Mihail
759 Contributor
Your post has been viewed 120 times in one day. And... no answer.
That means that something is wrong with your post, because seems to be a simple question for experts.

Since I don't use VB with databases (I use VBA) is possible to misunderstand your code.
Any way... I think that you don't scan the entire Field(0).
In my opinion that must be done in a cycle (starting with first record and ending with the last record) and I don't see any cycle in your code.

Again, it is possible that I don't interpret correctly the instruction If (rs2.Fields(0) = copnme_txt.Text) Then
Jun 22 '13 #2
Killer42
8,435 Recognized Expert Expert
Can you please explain what you mean when you says "it is strucking" on the Update statement? Is it producing an error? If so, what error?

If the problem is that you're attempting to create a duplicate record, then it may be because you're only comparing your text (copnme_txt.Text) to the current record. What about all the other records?

I'd suggest considering one of the following approaches:
  • Check for a duplicate by using a Find - you might want to put this in a Function to keep your code simple. So you can say for example
    Expand|Select|Wrap|Line Numbers
    1. If RecordAlreadyExists(copnme_txt.Text) Then
    2.   reset
    3. Else
    4.   rs2.AddNew
    5.   rs2.Fields(0) = copnme_txt.Text
    6.   rs2.Update
    7.   reset
    8. End If
    9.  
  • Use error-handling to trap the "duplicate record" error. For example...
    Expand|Select|Wrap|Line Numbers
    1. On Error Resume Next ' Turn on error trapping
    2. rs2.AddNew
    3. rs2.Fields(0) = copnme_txt.Text
    4. rs2.Update
    5. If Error.Number <> [I forget the number] Then
    6.   Debug.Print Error.Description
    7. End If
    8. On Error Goto Next ' Turn off error trapping
    9. reset
    10.  
Jul 9 '13 #3

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

Similar topics

0
2932
by: Pato Secruza | last post by:
Hi everyone! I have a really frustrating error and need help. I’m trying to do a function that gets the properties and names of the fields in a MS Access database using ASP. I haven’t...
1
1772
by: Jameel | last post by:
how do i find duplicate records in ASP.net/ADO.net , i know how to do it in classic asp, anything appreciated code,tutorial links etc.. (if rs.eof then add record else error message end if )
2
1861
by: Avatar | last post by:
Hi: My team is developing a project where a client app needs to interact with a remote Access database using a Web Service. The client app, the Web Service and the database accessing layer are...
0
1190
by: Burki | last post by:
Hi I want to know how to configure Access database using Enterprise Library Data block. I want to be able to spacify local path to mdb file in configuration file. I do not want users to creat...
1
3284
by: swatijogdand | last post by:
How to link table of sql server to access database using ado?
0
1172
by: swatijogdand | last post by:
Hi..... Again, it's really very urgent. does nebody have the code for connecting a SQL Server table to an access database using ADOX ??? Thanx in adavance, Regards, Swati
7
10436
by: mahipalerasani | last post by:
I am trying to connect to the Access database for querying, inserting and updating the data using 'C' API's. If somebody has code to connect to Access Database using C API's can you you please...
1
2595
by: Sunlis | last post by:
I need to find a way to communicate with a MS Access database using Javascript, PHP, or some other client-side scripting. It's for a Computer Science exam, and I cannot solve this problem. Users...
0
1634
by: marcoseraphin | last post by:
How to delete a relation in access database using .Net 2.0 C# ? My problem: I have a table which has a foreign key contraint to another table. I want to delete this relation using a ALTER Table...
7
6385
by: mukeshrasm | last post by:
hello everyone I want to delete the selected records from database using checkbox. whch is generated dyanamically and checkbox is also generated dynamically,using php. so please help me. if you...
0
7225
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,...
0
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7382
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...
1
7042
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...
0
7495
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...
0
4707
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...
0
3181
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1556
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 ...
1
766
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.