Hi p-rat:
Are you aware that the column property of a combo box is zero based, so column(1) is actually the second field in the combo box's row source?
I don't remember off-hand what the error code means, but my guess is it has to do with trying to put a string value (location) into a control bound to a field set up for a number (locationId), in this case due to using the wrong column() poperty value (column(1) when you probably need column(0).
Just as an aside, there's something odd about your treatment of locationId. I assume that's the primary key in your table used as the lookup source for the combo box, but if that's the case then it should probably be an autonumber field, NOT appear on the form that users enter new locations in, and NOT appear on the main form. Autonumber primary keys have no meaning to users and should be hidden from them. There also isn't a need to copy the value of locationID from the combo box to the text control on the main form, since 1. users probably don't need to see it (or probably shouldn't need to, anyway), and 2. the value is already in the combo box and can be pulled from there anytime you actually do need it.
Feel free to ignore the last paragraph. My direct answer to your question came in the first one.
HTH, CW
"p-rat" wrote:
[Quoted Text] > I have a form where I have a combo box that is a lookup from a table > where there are only two fields 'location' and 'locationID'. It looks > up the 'location'. If the location isn't in the table the user has the > ability to add this to the table or list (a form will appear with two > text boxes 'location' and 'locationID' for the new values. It will > then ask if you want this value added to the list. All works fine. > > My problem is that I then have a autofill field after this that shows > the LocationID (after update event of combobox): > > Me.LocationID.Value = Me.Location.Column(1) > > When I tab out of the combo box and expect the Location ID to autofill > into the next field there appears an error box: > > run time error '2113' > the value you entered isn't valid for this field > > I have no clue to what is taking place. If anyone could point me in > the right direction it would be great. Thanks. > > > >
|