473,387 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Duplicate in ms access table

If somebody can help me to tell what I do wrong. If I take the code with rstCrotal I can enter the data in the table, NRCRO is texbox on form an I will like to check if the column called NRCROTRAL is not entered already a record with the same number. Any help appreciated .

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSavenew_Click()
  2. On Error GoTo Err_cmdSaveNew_Click
  3. Dim dbs As Database
  4. Dim rst As Recordset
  5. Dim res As Integer
  6. Dim rstCrotral As Recordset
  7.  
  8. If Len(Me.NRCRO) > 0 And Len(Me.DataIntrare) > 0 And Len(Me.cod) > 0 Then
  9. Set dbs = CurrentDb
  10. Set rst = dbs.OpenRecordset("tblBovine")
  11. Set rstCrotral = dbs.OpenRecordset("tblBovine")
  12.  
  13.   rstCrotral.FindFirst "NRCROTRAL = '" & Me.NRCRO & "'"
  14.  
  15.         If rstCrotral.NoMatch = True Then
  16. MyLine:        rst.AddNew
  17.                rst!NRINV = Me.NRINV
  18.                rst!NRCROTRAL = Me.NRCRO
  19.                rst!DataIntrare = Me.DataIntrare
  20.                rst!CodSC = Me.CodSC
  21.                rst!CodGest = Me.CodGest
  22.                rst!cod = Me.cod
  23.                rst!sex = Me.sex
  24.                rst!Mama = Me.Mama
  25.                rst!Tata = Me.Tata
  26.                rst!Comentarii = Me.Tata
  27.                rst!Datarec = Now()
  28.                rst!userid = Me.userid
  29.                rst!UM = "BUC"
  30.                rst.Update
  31.                rst.Close
  32.  
  33.                Me.NRINV = Null
  34.                Me.NRCRO = Null
  35.                Me.DataIntrare = Null
  36.                Me.cod = Null
  37.                Me.sex = False
  38.                Me.Mama = Null
  39.                Me.Tata = Null
  40.                Me.Comentarii = Null
  41.                Me.cmbCodGest = Null
  42.                Me.Combo38 = Null
  43.                Me.NRCRO.SetFocus
  44.         End If
  45.         Else
  46.                MsgBox "Indroduceti informatiile", vbOKOnly
  47.       Me.NRINV.SetFocus
  48.  
  49.  
  50.     End If
  51.  
  52. Exit_cmdSaveNew_Click:
  53.     Exit Sub
  54.  
  55. 'Err_cmdSaveNew_Click:
  56.     MsgBox Err.Description
  57.     'Resume Exit_cmdSaveNew_Click
  58.  
  59. End Sub
  60.  
Nov 7 '07 #1
1 1298
nico5038
3,080 Expert 2GB
Did you check NRCROTRAL to be text and not numeric ?

Nic;o)
Nov 7 '07 #2

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

Similar topics

8
by: Kragen Sitaker | last post by:
ERROR: Cannot insert a duplicate key into unique index pg_class_relname_nsp_index We've been getting this error in our application every once in a while --- typically once an hour to once a day,...
2
by: Pablo | last post by:
Hello, there, I have a table tblData which has pharmacy data. The table has following fields: ClaimNum, LineNum... The ClaimNum has claim number which is 12 characters. LineNum is NULL. The...
2
by: ms | last post by:
Access 2000: I am trying to delete duplicate records imported to a staging table leaving one of the duplicates to be imported into the live table. A unique record is based on a composite key of 3...
3
by: dan graziano | last post by:
Hi, How do you suggest is the best way to check for duplicate rows in an access table. And once one knows if there are duplicates, to remove all but one. In my access table, there are 5...
6
by: sara | last post by:
I have a procedure to automate bringing several Excel files into our Access tables, on a daily basis. The problem is that if the user has a problem, and tries to run the import again (maybe 3...
8
by: Iona | last post by:
Hi Allan, I'm using a nifty piece of code you put on here some time back to do a duplicate entry check as below. I'm using to check for duplicate names. However I am getting an error message on...
9
by: Tom_F | last post by:
To comp.databases.ms-access -- I just discovered, to my more than mild dismay, that some tables in my Microsoft Access 2003 database have duplicate numbers in the "AutoNumber" field. (Field...
9
by: rjshrader | last post by:
I have a table (tblStatus) with three fields (CustomerID, StatusType and StatusDate). I use an unbound form with three text boxes to enter data into the table when a command button (cmdSave) is...
4
by: N2Deep | last post by:
I have a table named SUPPORT DATA, I have a field named Serial Number. In the Serial Number field I have many duplicates, and I only want one of each. Sample serials ABB045000MG, JBX05050016 ...
1
by: billesque | last post by:
Hello! I was wondering if it's possible to take a table in Microsoft Access that contains duplicate records (though not exactly identical) and create queries for use in a form. The form, currently...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...

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.