Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 18th, 2005, 08:09 AM
Authorized User
 
Join Date: Feb 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Validation to Prevent Duplicates

Hi,

I have created a database that monitors containers that are being hired. When a container is hired some details are entered and remains the same until we receive an invoice to state that the hire has stopped. Subsequently, the database is updated and an invoice sent. The container is then hired out again and some details are entered on the database and so on.
There are two check boxes to state whether the container hire has been completed and whether the client has been invoiced.

I am attempting to stop duplicate entries of container numbers being entered onto the database when the transactions are not complete and the client has not been invoiced.

I cannot use a primary key because the containers are reused and hence the container number will be on the field more than once. I have also tried a find duplicates query, but this found duplicates in the whole table and returned only the duplicates that were in the criteria I had specified.

Basically, I want the validation or whatever to prevent duplicates only when the two check boxes are 0.

It is seeming that the only option will be VBA.

Thanks in anticipation for your help.

All the best,


Roly
 
Old August 19th, 2005, 08:21 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Have the AfterUpdate event of the container number field open a recordset.
You can create a recordset of only the container number that was just submitted.
Then loop through the recordset and check the state of the two check boxes for each transaction.

If chkComplete = 0 AND chkClientInvoiced = 0 Then
   MsgBox "A previous transaction with this container is not complete." & vbCrLf & _
          '"Add text to tell the user what to do."
   'code to roll back transaction, or cancel transaction.
End If

HTH



mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking for Duplicates timeware ASP.NET 2.0 Professional 2 July 20th, 2006 08:41 AM
Yes to duplicates MMJiggy62 Beginning VB 6 3 July 14th, 2006 11:51 AM
Delete duplicates? boson SQL Language 2 August 11th, 2004 04:47 PM
Prevent Product Duplicates lucian Dreamweaver (all versions) 1 September 20th, 2003 02:08 PM
Duplicates ashley_y Access 11 August 14th, 2003 03:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.