Sasham
Posts: 2
|
| Posted: 02/08/2009, 9:10 AM |
|
I have the following table:
wms_results[rec_id, lab_id, sample, SPC_A, SPC_B, Coliformb_A, Coliformb_B, Coliformf_A, Coliformf_B].
The sample field can be of value A & B & C & D. (Each lab can only enter 4 samples)
If lab ABC01 enters results for all 4 samples, how do I stop inserts of duplicate values of sample.
Edit and delate are allowed at any time.
If using the property 'unique' on field sample, it prevents other labs from entering these samples.
Using php4 & mysql 3.23
I am new to CC4 and struggle with the custom code.
|
 |
 |
damian
Posts: 838
|
| Posted: 02/08/2009, 6:55 PM |
|
wouldnt you put unique on the lab_id if they can only enter once?
_________________
if you found this post useful take the time to help someone else.... :)
|
 |
 |
damian
Posts: 838
|
| Posted: 02/08/2009, 6:59 PM |
|
or in page before show do a check on the table for all records where lab_id=CCGetUserID() (assuming this is your case! - otherwise use similar expression) - if the result = 1 hide the add/edit grid and display a message - "thankyou - we have already received your results for this program"
_________________
if you found this post useful take the time to help someone else.... :)
|
 |
 |
Sasham
Posts: 2
|
| Posted: 02/08/2009, 9:41 PM |
|
Thanks Damian,
Each lab can submit 4 samples ie A,B,C,D then no more. Making lab_id unique will only allow each lab to submit one sample.
I am considering splitting each sample into its own table which will make the coding simpler, but will complicate later analysis of the data where I need it all in one table.
The labs also need to be able to go in and edit the results after they have submitted the 4 samples, so I cannot hide the edit function, only prevent adding more duplicate samples.
Let me know if there is an easier way that I am missing here!
|
 |
 |
|