Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Validate for duplicate values during data entry

Posted on 2004-08-20
6
Medium Priority
?
266 Views
Last Modified: 2012-05-05
frmAddMedication allows a user to select  a med, enter dosage, date, dr. Before the record is saved I want to check to ensure that resident is not already on that med.  This form is bound to tblResidentMedication.  Investigating the before update event looks great however, I am just not sure how to code.
0
Comment
Question by:JamieRhodes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 11854969
What is resident? and which field on the table you want it check for existence?
0
 
LVL 16

Accepted Solution

by:
Nestorio earned 1000 total points
ID: 11855447
Try this:

Private Sub Resident_BeforeUpdate(Cancel As Integer)
RecordsetClone.FindFirst "Resident = '" & Me.Resident & "'"
If Not RecordsetClone.NoMatch Then
MsgBox "Duplicate Key. Please reenter"
Cancel = -1
End If
End Sub


Assuming Resident is the field name which no allow duplicates.
0
 
LVL 9

Expert Comment

by:solution46
ID: 11858436
Jamie,

sounds like you're talking about patients resident at a hospital or similar? If so, then presumably you have some way of tracking patient 'visits' or 'episodes' or whatever terminology your place uses. If you have a unique way of identifying each visit, rather than each patient, you could try setting a primary key (or other unique index) across the fields MedicationID and VisitID. Just thought, if there is some reason why the patient would only ever visit once, then you can make the index unique across the fields PatientID and MedicationID. If you could have multiple visit from the same patient, but no way of identifying them, you are going to have difficulty detecting when a duplicate PatientID / MedicationID is genuine (in some cases it may be historical and not relevant to the current visit).

With the unique index in place, the system will fail every time you try to enter a duplicate VisitID / MedicationID; the error message is not particularly user-friendly but this at least a simple solution.


s46.
0
 

Author Comment

by:JamieRhodes
ID: 12607533
solution46

I am not needing to track visits, just the meds the patient is on.


capricorn1

Resident/patient is the person. the table that the info is going into is tblResidentMedications

Nestorio

I will try it .
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question