473,387 Members | 1,464 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.

Prevent Duplicates in form that is allowed in table

I have an access database for recording client information at our food pantry.

We have a client form to record basic information then a subform to record each visit.
The client and visits are in separate tables. The rec_date is indexed to each client and since all records are kept in a table duplicate dates are allowed in the table for individual clients.

I need a way to prevent the users from entering duplicate dates in the subform when recording a visit.

I currently use a click control to start a new record.

Example users creates new record for client then does not think they recorded a record and creates an additional record. I need a way to eliminate that additional record creation. thanks Luther (know enough about VBA to be dangerous"
May 26 '17 #1

✓ answered by NeoPa

Hi Luther.

May I suggest you look into indices for your tables. Indices can be made up of multiple fields where necessary so you can ensure that more than one visit is never entered for a Client AND a Date. The same for the Client table.

Let us know how you get on or if you'd like more help.

9 903
NeoPa
32,556 Expert Mod 16PB
Hi Luther.

May I suggest you look into indices for your tables. Indices can be made up of multiple fields where necessary so you can ensure that more than one visit is never entered for a Client AND a Date. The same for the Client table.

Let us know how you get on or if you'd like more help.
May 26 '17 #2
PhilOfWalton
1,430 Expert 1GB
I frequently use NeoPa's method with indexes, but there is a caveat with dates. Providing the date is a whole date and there is no time element in it, then there is no problem, but from the point of view of indexing, obviously 27 May 2017 is different from 27 may 2017 10AM.

If there is the slightest possibility that time could be entered, the simplest way is on the BeforeUpdate event to check the formatted date in the existing table with the formatted date just entered.
Don't forget that this is a string comparison, so you will need to use double quotes.

Phil
May 27 '17 #3
Thank You = works perfectly
May 27 '17 #4
NeoPa
32,556 Expert Mod 16PB
Hi Phil.

If anyone were to require a situation where dates, specifically, were expected to be unique but that times were also entered, then it would surely make good sense to separate the dates and the times and simply include the date element in the index without the time element. I struggle to think of a scenario where that might be required but experience tells me that you can't always rely on experience to show you everything. New things come up all the time.

Or to put it another way, just because I can't think of something doesn't mean it can't occur.
May 27 '17 #5
NeoPa
32,556 Expert Mod 16PB
@Luther.

It's always gratifying when someone asks for help then finds their own solution with just a hint of help.

Good for you :-)
May 27 '17 #6
PhilOfWalton
1,430 Expert 1GB
@ NeoPa

Ah, Neopa, if only you weren't so young (in comparison anyway). In the good old days people paid bills with cheques and I was treasurer of various sailing / yachting clubs. When subscriptions were due, we frequently got 40 or 50 cheques a day, and the situation, similar to Luther's, is that we didn't want duplicates posted against any Member.

So when the cheque was entered, the default date was Now() rather than Date(). Although the time element of the date was totally irrelevant, it kept the cheques in order. A list was prepared in date/time order and the cheques sent to the bank in that order.

By and large, the Bank processed the cheques in the same order, so it was very easy to reconcile the bank Statement against the Club's entries.

Obviously the list could have been sorted by Date & PaymentID Order, but the date & fictitious time seemed more flexible & intuitive.

Phil
May 28 '17 #7
NeoPa
32,556 Expert Mod 16PB
That'd do it Phil :-) As I say, just because I couldn't think of a scenario doesn't mean there couldn't be one.

In such a scenario, assuming that Client & Date, rather than Client & DateTime, were required to be unique, splitting the date and time elements and including the date with the client ref in the PK would do the business for you.
May 28 '17 #8
Fortunately I use date only - so the table is based on client record + unique date. Thank you for your suggestion - I worked with access before I retired, unfortunately every time I try something new I need to be retrained.
May 28 '17 #9
NeoPa
32,556 Expert Mod 16PB
Hi Luther.

You're very welcome. You didn't require retraining as much as a small hint. We all need that when we try something outside of our comfort-zone. Not everyone does of course, so good for you.
May 28 '17 #10

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

Similar topics

3
by: entoone | last post by:
I have an html form, that has fields and when the submit button is pressed, the information is transferred to a php file. Which then inserts the data into my sql database. How can I go about...
3
by: kjaggi | last post by:
I am trying to either write a trigger or a check constraint to prevent duplicates in my table. There are two columns I need to look at for the duplicates and only one combo value for both columns...
6
by: Miguelito Bain | last post by:
hi everybody- i have a form with 2 fields on it that i want the user to fill out before he or she can save the record, close the record, or move to the next record, etc... here's the code i...
2
by: Bill Hand | last post by:
Is it possible to open a form from table and have it access a given record? I want to be able to query all baseball cards with the last name Jones and have it open a table. In each record of...
2
by: Gidi | last post by:
hello, i have a mainForm that has few buttons which open different forms. how can i prevent a form that is already open to be open again ( i don't want to close the mainForm)? thanks....
3
by: AK | last post by:
Hi Our product uses MS-SQL Server 2000. One of our customer has 10 installations with each installation stroring data in its own database. Now the customer wants to consolidate these databases...
3
by: KayC | last post by:
Hi Background info: I am running Access 2000 I have a form bound to a blank table When a user clicks a button the form opens in datasheet view User enters data into form and closes form User...
0
by: abhishekjethwani | last post by:
How to write a query to access tree structure form multi table. I m having five tables from them first table give me a data which act as the parameter for query for the second table and the two...
11
beacon
by: beacon | last post by:
Hi everybody, I created a database that links one table from an ODBC data source. I saved my password and UID to the data source so neither myself nor anyone else would have to login each time...
7
by: alexrubio | last post by:
{{ Split from: Using DLookUp to prevent duplicates in Form }} Hi all, I was just tasked at tweaking the above macro and again I cannot find the right combination... I need to put an...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
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,...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.