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

Create Duplicate records

Hi,

I would like to create a table that will allow only two records per
date entered. So you should be able to input as many dates as you
like, but you can have each date only twice! It's a database for
patients receiving a specific treatment (We cannot have more than 2
patients/day). I want this restriction so as to ensure we don't
overbook the rooms.

At the moment I have to different tables , in each one of which the
date field is a "no duplicates" one. I then merge the two tables using
a union query. This though is not good enough as you are not allowed
to update the records in a union query.

Any better ideas?

thnx

Laertes
Nov 12 '05 #1
2 4226
Why not have sub routine before update of the TreatmentDate like

SubTreatmentDate_BeforeUpdate(Cancel As Integer

Dim MyDb as database
Dim MySet as recordset
Dim SQLStg as string

Set MyDb = CurrentDb
SQLStg = "SELECT TreatmentDate, Count(TreatmentDate) AS
CountOfTreatmentDate "
SQLStg = SQLStg & "FROM MyTable "
SQLStg = SQLStg & "GROUP BY TreatmentDate "
SQLStg = SQLStg & "HAVING TreatmentDate = " & TreatmentDatealexander &
";"

Set MySet = MyDb.OpenRecordSet(SQLStg)
If MySet!CountOfTreatmentDate >= 2 then
Msgbox "You already have 2 patients for this date",vbCritical
cancel = true
end if
MySet.Close
Set MySet = nothing

end sub
This will hive the number of times that date has been entered

Phil
"Laertes" <bi******@btopenworld.com> wrote in message
news:b2*************************@posting.google.co m...
Hi,

I would like to create a table that will allow only two records per
date entered. So you should be able to input as many dates as you
like, but you can have each date only twice! It's a database for
patients receiving a specific treatment (We cannot have more than 2
patients/day). I want this restriction so as to ensure we don't
overbook the rooms.

At the moment I have to different tables , in each one of which the
date field is a "no duplicates" one. I then merge the two tables using
a union query. This though is not good enough as you are not allowed
to update the records in a union query.

Any better ideas?

thnx

Laertes

Nov 12 '05 #2
Thnx a lot! It took me a while but I finally managed to figure out how
to modify your code to my requirements!!!
Laertes
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Gary Lundquest | last post by:
It appears to me that MySQL version 4 returns an error messge when doing an Insert that results in duplicate entries. Version 3 did NOT return an error - it dropped the duplicate entries and ran...
10
by: Mark | last post by:
I have a table about people containing 25 fields. The table contains the usual fields - first, last, address, city, state and zip. There is no primary key. These fields all have data with the...
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...
0
by: B.N.Prabhu | last post by:
Hi, I have a DataTable with several rows. Its having 20 Columns. when i click the Insert button then i have to check the Database Rows. Whether these new rows are already available in the...
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...
6
by: Alvin SIU | last post by:
Hi all, I have a table in Db2 v8 like this: Team Name Role ------ -------- --------------------- A Superman Leader A Batman Member A WonderWoman Member B ...
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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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...

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.