473,326 Members | 2,133 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,326 software developers and data experts.

Duplicate record check prevents modifying of records

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("Duplicate 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 2520
Stewart Ross
2,545 Expert Mod 2GB
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 Expert 2GB
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
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...
6
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...
2
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...
2
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...
6
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...
8
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...
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...
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,...
1
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.