473,659 Members | 3,348 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Duplicate record check prevents modifying of records

1 New Member
Hello, I have a duplicate record check written in VB for a check in/check out database. Here's the pseudocode, written for the BeforeUpdate property on the form:

If DCount(search for records with the same TimeIn and TimeOut) > 0 Then
MsgBox("Duplica te record found")
Undo and set focus
End Sub

This code works fine if you try to add a new record that has duplicate times for TimeIn and TimeOut, but when I try to modify an already-inputted record using the form, it gives me the duplicate record error.

The reason this happens, as I can deduce it, is because the check is performed before the record is updated. However, I can't think of any way to get around this without removing the check itself. Is there any way to differentiate between adding a new record and simply updating one? Thanks!
Mar 12 '08 #1
2 2541
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi. You could use similar checking code called from the After Update events of your TimeIn and TimeOut controls. That way you are using the updated values in your lookup. To undo the changes if these result in a duplicate you just use the undo method of that control after displaying your error message to undo the changes.

-Stewart
Mar 15 '08 #2
missinglinq
3,532 Recognized Expert Specialist
As you say, you need to differentiate between new records and existing records and then only do your dup check on new records. This is done by wrapping your code inside of Me.NewRecord:

Expand|Select|Wrap|Line Numbers
  1.   If Me.NewRecord Then
  2.   If DCount(search for records with the same TimeIn and TimeOut) > 0 Then
  3.   MsgBox("Duplicate record found")
  4.   Undo and set focus
  5.  End If
  6. End If 
  7.  
Welcome to TheScripts!

Linq ;0)>
Mar 15 '08 #3

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

Similar topics

1
2972
by: JStrummer | last post by:
I just put together a PHP mailing list sign-up page that posts to a mySQL DB. The PHP script prevents INSERTs when the email address is already located in the database. Problem: I need to import some flat-files that stored the signups, prior to this new form. Email addresses weren't checked, so there are a lot of records that have the same email address. Once I import these into the table, how would I go about putting together a SQL...
6
3068
by: 6thirty | last post by:
Hi, I've created a stocktaking database using Access XP. This is indexed by two fields - part number and shelf location. I am currently inputting all the data via a form. When I have entered a record such as: part number 202354-001 location C1-01
2
5559
by: Emmett Power | last post by:
Hi, I have an Access table with a number of records which refer to the same person but with data in different fields. So for example the table would look like this: Name..............Field 1...................Field 2 Fred Smith........Red John Brown........Blue Fred Smith...................................Truck
2
3229
by: stranger | last post by:
My database is set up so people can input parts orders. Sometimes they order the same parts on a monthly basis. I want to be able to duplicate past parts orders and have it pasted in with a new primary key. My first attempt seemed to work(minus a few Microsoft glitches). I used a "duplicate" command button at first. This made a copy of the record but failed to bump up the primary key by 1 number(so it seemed). Actually, the number did...
6
6516
by: planetthoughtful | last post by:
Hi All, I have a C# ASP.NET page that submits back to itself to insert details from a form into a database table. When / if the user refreshes the page (and gets the standard warning that POST data will be resubmitted), the previously submitted record is sumbitted again, and a duplicate record is inserted into the table. In PHP I would have avoided this by submitting the form to a processing page, which would then automatically...
8
2694
by: mindwarp | last post by:
Hi, When a user submits / posts data my php script Inserts data into my database. If they refresh the script or click back and click submit again I get duplicate record. Is there an easy solution to this? Or do I need to create a hidden field which contains some sort of
9
11223
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 Size is set to "Long Integer", and New Values is set to "Increment".) I know that an old version of the Jet database engine can cause this problem, but my version of msjet40.dll is 4.0.8618.0, which is supposedly bug-free in this respect. I am...
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...
1
7265
by: xraive | last post by:
I have a problem with this. Currently I am trying Allen's code and i am not successful. Current Design Table1 (Main Form) TravelID (PK) ApprovedBY EntreredBy BudgetCode ExpenseCode
0
8428
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
8627
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
7356
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
6179
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
5649
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
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2752
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
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.