JayT
Posts: 14
|
| Posted: 10/17/2006, 3:53 AM |
|
Hi,
Been having problems, trying to generate an autonumber (ID number) for a new record to be put into the database.
Using codecharge 3.0, php and ms access database;
in Access i have set field’s data type to Autonumber, but then had problems. When i went to save the new record it wouldnt update the ID field, gave an error.
Once i changed the field data type to number it updated the record, without any problems.
Now i need to generate a autonumber for the ID field, so when someone goes into the web page and decides to add a new record, it populates a new form with the ID field filled in will a new number.
i've also got another enquiry on the same record form, when i retreive records from the database some of the radio button values dnt get displayed??
i checked the database and the values do get stored, dont understand why it dnt pick them up the values as all the rest of the radio buttons are setup the same??
any ideas, as this info is urgently required, any help would be appreciated????????
Thanks everyone
|
 |
 |
Rene S
|
| Posted: 10/17/2006, 5:00 AM |
|
Hi,
I'm not a guru, but I think that in the end it will be easier to sort out your autonumber field in Access than trying to generate your own autonumber. Are you trying to update multiple tables with one insert action?
Rene S
|
|
|
 |
Jay
|
| Posted: 10/17/2006, 7:40 AM |
|
im trying to update multiple tables, its just the one table,
I understand that it will be easier to sort it out in Access.
Just seems that codecharge presents errors if i try an update the ID field that is a primary key with data type autonumber with increment facility on it.
error i get is
Database error: [Microsoft][ODBC Microsoft Access Driver] Cannot update 'ID'; field not updateable.
|
|
|
 |
Jay
|
| Posted: 10/17/2006, 7:41 AM |
|
sorry, i'm not trying to update multiple tables
|
|
|
 |
Marcus
Posts: 49
|
| Posted: 10/17/2006, 10:18 AM |
|
Use the autonumber generated by Access. That's the easiest way.
You can generate your own number from the CCS record count variable and display it as a number.
|
 |
 |
Rene S
|
| Posted: 10/17/2006, 10:49 AM |
|
The error states that you are trying to "update" the ID field, I think that it is not possible to "update" an autonumber field, you can however update the other fields of that record. (Still not a guru, so I can't give you a better answer)
Goodluck,
Rene S
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 10/17/2006, 12:49 PM |
|
Yes, Rene is correct - you should not and cannot update an autonumber field. Such field values can only be generated/incremented automatically by the database, thus you must not include such fields in your forms/pages.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
JayT
Posts: 14
|
| Posted: 10/18/2006, 4:32 AM |
|
Thanks everyone for your support,
The only thing is that, the ID field in this form individually identifies the record, so it is required. Other wise the person who fills out the form, has not got a unique number for the record.
Is there any other way around this, as this is the only thing left for me to complete the form.
Thanks gain
|
 |
 |
E43509
Posts: 283
|
| Posted: 10/18/2006, 5:00 AM |
|
I guess I'll weigh in on this.
Simpliest solution ... don't put the ID on the entry form as MS Access will auto populate the field behind the scenes when you do an insert.
Or change the field from autonumber to a number field, keep it a key field, put on a hidden field on the form, and in the before insert event, select max(mykey) +1 from mytable and use that value for the hidden field. Not a good way to do it if you have many people using the application and two people commit the form at the same time. One will ungracefully error out when they both get the same max + 1 value. But in small apps you can get away with this.
If you need the ID that is auto generated after the insert, then this old codecharge article may be useful http://www.gotocode.com/art.asp?art_id=80&
|
 |
 |
Benjamin Krajmalnik
|
| Posted: 10/18/2006, 8:29 PM |
|
Since the field is system generated, do not create an entry field for it.
Otherwise you will have a problem.
There are 2 options which you have:
1. Make the field a label if it must be shown (or remove it altogether).
2. If you absolutely must have it as an entry field (probably tagged
readonly), then you are going to have to use cusstom insert so that it does
not try to populate it (and probably likewise on update).
"Jay" <Jay@forum.codecharge> wrote in message
news:24534eb5faa540@news.codecharge.com...
> im trying to update multiple tables, its just the one table,
> I understand that it will be easier to sort it out in Access.
>
> Just seems that codecharge presents errors if i try an update the ID field
> that
> is a primary key with data type autonumber with increment facility on it.
>
> error i get is
>
> Database error: [Microsoft][ODBC Microsoft Access Driver] Cannot update
> 'ID';
> field not updateable.
>
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
Benjamin Krajmalnik
|
| Posted: 10/18/2006, 8:30 PM |
|
Jay,
YOu can put it in your form as a label.
Labels do not generate code for an update.
"JayT" <JayT@forum.codecharge> wrote in message
news:2453610caed9aa@news.codecharge.com...
> Thanks everyone for your support,
>
> The only thing is that, the ID field in this form individually identifies
> the
> record, so it is required. Other wise the person who fills out the form,
> has
> not got a unique number for the record.
>
> Is there any other way around this, as this is the only thing left for me
> to
> complete the form.
>
> Thanks gain
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
JayT
Posts: 14
|
| Posted: 10/19/2006, 1:11 AM |
|
Thanks everyone for your support, changed the ID to a label and it works.
Just one other question, when you add a new record it does not show the ID, because i understand it is populated from the database.
Is there any way of creating a pop up box related to just the ID field, so the user can know what ID the record is stored under.
If there are Simultaneous connection its going to be difficult for the user to find the record which they have created!!!?????
Once again thanks people, would have been stuck for ages if it werent for you lot. Takecare.
|
 |
 |
|