Unique vs Edited can you do both?

csdrex87

Registered User.
Local time
Today, 14:09
Joined
Jul 1, 2009
Messages
66
So I'm working on an algorithm to prevent the user from putting in duplicate records for the same employee on a particular date. BUT i DO want to allow the user to edit his previous post. As a result I cant do a cancel on the before update but if i ignore the before update then I cant guarantee unique data entry for that particular employee's date. Any suggestions? (I have the code for doing both... its the algorithm that im having problems with)

Thanks for your help
 
if its a new record

me.newrecord will be true


if its editing an old record

me.newrecord will be false


does that help?
 
Not particularly. My problem is that its a bound form and if i attempt to go to a new record before preventing the Update then it will automatically save. And if i restrict the update in some way it will mess with the rest of the save things.

Currently im attempting to work on an algorithm for my buttons and going to attempt to ignore the update altogether. I think the only way im going to be able to do it is for each button to close the current form with acSaveNo and then open it up for the particular record that they were wanting to edit. But then again im not quite sure thats even going to work.
 
I think the only way im going to be able to do it is for each button to close the current form with acSaveNo
acSaveNo has NOTHING to do with RECORDS. It has to do with saving DESIGN changes to the form and nothing else.

You can check in your Before Update event of the form whether something exists or not. If it does you can cancel the update and do a Me.Undo and then navigate to that other record.
 
Ah thank you for clearing that up. I had no idea :-( alright i'll try what you suggested.
 
one way is to have a unique key on the file keyed to employee and date

then access will let you edit existing records, but not let you add a duplicate record

the only problem is that you wont find out until you try to save the whole form (which works but could be realy irritating, and is not user-friendly


now, one way to overcome this is

to test in the after update event for both the employee and date (you need the same test in both (call a common function) as you want to test on changes to either of these.

so, if both of these are not null, then do a dlookup to see if the record already exists, with these fields as the key value.

if it does, warn the user
if it doesn't let him carry on.
 

Users who are viewing this thread

Back
Top Bottom