Assiging the primary value back to Text Box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ramdil
    New Member
    • Dec 2007
    • 46

    Assiging the primary value back to Text Box

    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
    [CODE=vb]With Me.List15
    For i = 0 To .ListCount - 1
    If .Selected(i) = True Then
    Me.Fare_Line_Id .Value = .Column(0, i)---error comes here.
    Me.Name.Value = .Column(1, i)
    Me.Age.Value = .Column(2, i)
    End If
    Next i
    End With[/CODE]

    Thanks in advance
    Last edited by Scott Price; Feb 27 '08, 04:46 PM. Reason: code tags
  • FishVal
    Recognized Expert Specialist
    • Jun 2007
    • 2656

    #2
    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

    Comment

    • Scott Price
      Recognized Expert Top Contributor
      • Jul 2007
      • 1384

      #3
      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

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32633

        #4
        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.

        Comment

        • ramdil
          New Member
          • Dec 2007
          • 46

          #5
          Hi
          Thanks for the reply,I am trying to update the record..




          Originally posted by NeoPa
          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.

          Comment

          • ramdil
            New Member
            • Dec 2007
            • 46

            #6
            Hi
            Thanks for the reply,Yes ,It is bound to datatype autonumber


            Originally posted by FishVal
            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

            Comment

            • ramdil
              New Member
              • Dec 2007
              • 46

              #7
              Hi
              Thanks for the reply,My aim was to update the record with selected primary key id..




              Originally posted by Scott Price
              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

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32633

                #8
                Originally posted by ramdil
                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.

                Comment

                • ramdil
                  New Member
                  • Dec 2007
                  • 46

                  #9
                  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.
                  Originally posted by NeoPa
                  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.

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32633

                    #10
                    Oh good. I like it best when you find your own answers :) It indicates you're learning from the issues.

                    Congratulations :)

                    Comment

                    Working...