By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,396 Members | 2,501 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,396 IT Pros & Developers. It's quick & easy.

Assiging the primary value back to Text Box

P: 46
Hi All
I have a list box in a form with three columns
1.ID
2.Name
3.Age
In the same form i have three text boxes corresponding for the above columns.
The form record source property is set to the Table.ID field is autonumber.
Now i am facing a error.When i select one row in a list box ,i want to assign the values in the list box row back to text box for updation purpose.Now Name and age i am able to assign but for ID it is showing the error message
"You cant assign a value to this object".Can any one advise me pls
The code in my listview dbl click event is as below
Expand|Select|Wrap|Line Numbers
  1. With Me.List15
  2.       For i = 0 To .ListCount - 1
  3.          If .Selected(i) = True Then
  4.              Me.Fare_Line_Id.Value = .Column(0, i)---error comes here.
  5.              Me.Name.Value = .Column(1, i)
  6.              Me.Age.Value = .Column(2, i)
  7.          End If
  8.     Next i
  9. End With
Thanks in advance
Feb 27 '08 #1
Share this Question
Share on Google+
9 Replies


FishVal
Expert 2.5K+
P: 2,653
Hi, ramdil.

Are you sure [Fare_Line_Id] control has Value property and it is not bound to any read-only table field?

Kind regards,
Fish
Feb 27 '08 #2

Scott Price
Expert 100+
P: 1,384
Autonumber's are not user updateable, nor should they be! Access's autonumber data type was not created for user interaction, only for uniquely identifying each record in a table.

If you have a real requirement for a primary key that IS user updateable, you'll need to write some code that creates the automatically incrementing key value (for which there are several threads on this site).

Other than a business requirement (such as the bosses saying you need to have each record identified with an alphanumeric code such as TBL0001, or a hidden date such as 02280800001) I can't see the need for you to change the ID field.

Regards,
Scott
Feb 27 '08 #3

NeoPa
Expert Mod 15k+
P: 31,494
By the way, are you intending to create a new record with this or update an existing one?
Your code seems to be attempting the latter.
Feb 28 '08 #4

P: 46
Hi
Thanks for the reply,I am trying to update the record..




By the way, are you intending to create a new record with this or update an existing one?
Your code seems to be attempting the latter.
Feb 29 '08 #5

P: 46
Hi
Thanks for the reply,Yes ,It is bound to datatype autonumber


Hi, ramdil.

Are you sure [Fare_Line_Id] control has Value property and it is not bound to any read-only table field?

Kind regards,
Fish
Feb 29 '08 #6

P: 46
Hi
Thanks for the reply,My aim was to update the record with selected primary key id..




Autonumber's are not user updateable, nor should they be! Access's autonumber data type was not created for user interaction, only for uniquely identifying each record in a table.

If you have a real requirement for a primary key that IS user updateable, you'll need to write some code that creates the automatically incrementing key value (for which there are several threads on this site).

Other than a business requirement (such as the bosses saying you need to have each record identified with an alphanumeric code such as TBL0001, or a hidden date such as 02280800001) I can't see the need for you to change the ID field.

Regards,
Scott
Feb 29 '08 #7

NeoPa
Expert Mod 15k+
P: 31,494
Hi
Thanks for the reply,I am trying to update the record..
This logic doesn't make much sense then.
Why would you update the (same) current record with multiple values? Each successive one would overwrite the previous one.
Feb 29 '08 #8

P: 46
Hi Thanks for the valid point

I have changed the logic and now i am updating the records based on the unique value and is working fine.
This logic doesn't make much sense then.
Why would you update the (same) current record with multiple vales? Each successive one would overwrite the previous one.
Mar 10 '08 #9

NeoPa
Expert Mod 15k+
P: 31,494
Oh good. I like it best when you find your own answers :) It indicates you're learning from the issues.

Congratulations :)
Mar 10 '08 #10

Post your reply

Sign in to post your reply or Sign up for a free account.