Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I populate an autonumber field from a multi column combo box

Status
Not open for further replies.

davejackson

Technical User
May 8, 2001
34
GB
I have a form with a header, details and 1 page of details with a subform. The record on the details/subform should be updated in 2 ways: Firstly by selecting the next/previous buttons and secondly by chosing a record from a combo box in the form header which contains three fields from a table (Client, City, ClientID). The key field (ClientID) is generated via an autonumber. Using the next/previous buttons works fine, but when I chose a record from the combo box, the key field in the ClientID text box is not updated using the code:
Me.City = Me.Client.Column(1)
Me.ClientID = Me.Client.Column(2) and I receive the error "You can't assign a value to this object". This also prevents me using the key field to retrieve the subform record.

As you can probably tell I am scrambling around as I am not very experienced so I would greatly appreciate any help that can be given.
 
You CANNOT assign a value to an AUTOnumber. When the textbox is bound to the field and you attempt to assign a value to the textbox, you are coincidentally attempting to assign the value to the controlsource (bound field). You need to retrieve the record in some other manner and let the record (retrievial) populate the controls. It would be a "good" idea to lock or disable the textbox or place the autonumber in a lable to preevent confusion from the error(s) generated when a user attempts to edit these values.


MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Michael, thanks for your reply but maybe I wasn't clear or didn't understand your reply. My combo box contains e.g. (DavidJackson London 0001) retrieved from a table containing (Client, City, ClientID). 0001 being the ClientID created initally. When I select this record I want to populate three fields: Client (the combo box), City (textbox, locked), ClientID (textbox, locked) with the values I have retrieved. The fields need to be bound so they will change as the next/previous record is selected. I accept that the code [Me.ClientID = Me.Client.Column(2)] doesn't work so was hoping for another way to insert the ClientID. The fields are not intended to be used to update this table but they are only for selecting a client so a seperate table on a subform can be updated with client orders. I hope this is clearer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top