473,382 Members | 1,809 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,382 software developers and data experts.

Warning when duplicate records

I have a field that permits duplicate records but I need to be warned when I enter a duplicate number. I used old posts to try to solv this problem but I keep getting the message "Procedure declaration does not match description of event or procedure having the same name" (with different codes). The field is named "NSC" and the table "1 - Principal". The code I used was:
Expand|Select|Wrap|Line Numbers
  1. Private Sub NSC_BeforeUpdate()
  2. Dim rslt As Integer
  3.    If Nz(DLookup("[NSC]", "1 - Principal", "[NSC]=" & Me.NSC), 0) <> 0 Then
  4.       rslt = MsgBox("Este NID já foi introduzido previamente. Deseja continuar?", vbYesNo)
  5.       If rslt = vbNo Then
  6.         Me.RecNo = Null
  7.          Me.RecNo.SetFocus
  8.       End If
  9.    End If
  10. End Sub
Can anybody tell me what am I doing wrong
Mar 21 '13 #1
1 1065
zmbd
5,501 Expert Mod 4TB
It is because your sub procedure is named incorrectly and doesn't have the correct augments.

Thank you for using the code tags. There are some troubleshooting and setup options that you should look at in the first section: >> Before Posting (VBA or SQL) Code.

As for your specific problem.
Open your form in design mode
Select the control [NSC]
Show the properties box for the control (right click context menu etc...)
Select the events tab
Select the before update event
Click on the [...] button
Select code (NOT macro!)
The vba editor will open
Cut and paste lines 2 thru 9 into the Sub procedure that Access has created for you.
Follow the steps that are outlined in the above link on compile and the like.


Also one should NEVER use non-alphanumerics (except for the underscore "_") for field, or table names. "1 - Principal" is asking for trouble. Even the space is not really a great thing even though it has become common.

>SQL Essentials: SQL Server Data Importing: Do's and Don'ts
Don't use non-alphanumeric characters in staging table/column names
You may not have control over how columns are initially named in the tables containing raw data, but I try to revise legacy column names that may contain spaces or other irregular characters. When column or table names contain non-alphanumeric characters, we're forced to delimit them with square brackets or double quotes. Not only is that kind of code harder to write, it's also harder to read.
Mar 21 '13 #2

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

Similar topics

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...
2
by: Carroll | last post by:
I'm looking for a way in SQL to find duplicate records in a single table, that are the same based on 3 columns, regardless of what is in the other columns in the duplicate records. I would like to...
2
by: jmarr02s | last post by:
I don't know what I am doing wrong I get duplicate records when I query Here is my SQL query code: SELECT Utilization_T.Facid, Utilization_T.Year, Utilization_T.Beds, Utilization_T.LicBeds,...
9
by: jjstevens | last post by:
I am trying to set up a message box warning (or open to some sort of other warning) when a duplicate record is entered. I do want to allow duplicate records but I am looking to warn when it does...
2
by: nethravathy | last post by:
Hi, The following table namely elcbtripselect contains 5147 records.I want to know wether this table contains duplicate records or not. I tried with following query 1)SELECT...
1
by: colin-whitehead | last post by:
I have 2 tables tblReports primary key UPN, plus numeric fields Effort, Attain, etc tblComments numeric primary key ID & textfield Text In the Query I select each record from tblReports...
4
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,...
2
by: nomvula | last post by:
hi guys i need some help to duplicate records on my form datasheet: here's the example of my form results: ClientLookup DateCaptured ForecastDate Description ForecastQuantity Forecast Actual UJ...
6
by: Dilip1983 | last post by:
Hi All, I want to delete duplicate records from a large table. There is one index(INDEX_U1) on 4 columns(col1,col2,col3,col4) which is in unusable state. First of all when i tried to rebuild...
6
by: Phil Stanton | last post by:
My Ak2 databas has been running successfully for many years althogh it gets upgraded regularly. I now find on this, and other dbs, when I delete a record I no longer get the message "You are...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.