Pinchas
|
| Posted: 10/09/2002, 7:37 AM |
|
CC2, begginer.
May be too simple but i dont see how.
In a Non automatic updated Primary key
I need to update the key in the insert state but not in the update state.
any solution without doing it in two separate pages: une for insert and one for update. ?
|
|
|
 |
Nicole
|
| Posted: 10/10/2002, 6:58 AM |
|
Pinchas,
Generate normal Record form with key field type set to hidden and ‘Key’ flag selected. Then create Custom Action event and modify insert sql statement.
I suggest you to create this event after the form is finished, because once custom action (or custom show) event is created no modifications made on the form (e.g. add/delete the field) aren’t integrated into generated code.
|
|
|
 |
Pinchas
|
| Posted: 10/10/2002, 8:24 AM |
|
Nicole.
This is realy excelent solution except that I didn't understand it.
and because I see it is not that simple,
and as i am a Begginer and not a programmer
will you be so kind to explain this again,
step by step, code relevant?
best regards.
|
|
|
 |
Steve
|
| Posted: 10/10/2002, 11:00 PM |
|
Make it easy on yourself and just add an Auto-Increment Primary Key. Then No additional Code will need to be added in any events. An Auto-Increment Primary-key doesn't have to be referenced. The table will then fit into the Code Charge models better.
You can still make other keys unique and define relatinships if need be.
Since you mentioned you are a beginner and not a programmer too, then I would design, or try to design as much as possible so you don't have to code anything in events.
|
|
|
 |
Pinchas
|
| Posted: 10/11/2002, 5:20 AM |
|
Steve
Thank you.
I adopt your advise of always adding Auto-Increment Primary Key.
But this doesnt help in this case because:
Suppose a PERSONS tablle which has two fields
1. Auto-Increment Primary Key
2. ID Number
3. Full Name
I design a Record Form
In "Edit" mode, You allow users to update Name But dont allow update ID Number of course
But in "insert mode" you want to allow all fields updated, including ID number.
So the sollution I think is to cause the ID field to be Hidden in Update mode only
or having two fields for IDnumber
One for textBox field and one a Label field
and display them conditionally (insert/update mode)
Am I wrong, or missed something?
|
|
|
 |
Steve
|
| Posted: 02/21/2003, 4:24 PM |
|
You can hide the field for update but what if the ID Number is typed in wrong and you can't update it? You would have to delete the record and add a new record. Then what about related records. They would not be propagated to the new person.
I would suggest that allow the ID Number to be updated. Make it unique too.
If the ID Number isn't a foreign key on another table, and it shouldn't be because it's not the primary key, what is the impact of having the ID Number change?
If it is a question of controlling access to fields, Then break the recork up into different forms. The first form can have fields updateble by the webmaster, the second form fields updateable by the adminsistrator, the third form fields updateable by a client. The form access can then be easily restricted based how the logged on. In fact I have some pages where the record is broken into multiple forms. A form for the client, administrator, and webmaster.
One rule of thumb that can be applied when designing a system is that the person who enters data, should be able to change the data. Of course there can be exception, such as a closed status on the object (record), or only allowed to Add.
If the ID Number can't ever be changed once enterd, then yes, you would want have a label and text box. Text box for Add mode; Label for all other modes. I would allow some way to change the ID number though as we all make typos, including the person that does the data entry on your pages.
But try to design so that coding can be minimized.
|
|
|
 |
|