Bound/updateable controls

B

bernie123

Hi Guys,

I have started to create a form with a combo box which holds the data
from this query:

SELECT Make & " " & Model AS Name, CarID, Price, Predecessor,
PredecessorID, IsPredecessor FROM tblCar;

The combobox only shows the fieldName there are text boxes below that
are bound to the combobox show most of the other data. Currently these
cannot be updated by the user, i get this error: control cant be
updated: its bound to expression ......

How can i make these textboxes updateable so that they update the
recordset?

Also: i want to display Predecessor in a combobox, but predecessor is
related to a CarID, if the IsPredecessor of a car is set to yes, the
car can be a predecessor of another car. I would like to show all
possible predecessors in the combo box and have this update the
database when changed too.

Any help would be great with this one.

Thanks b.
 
M

Michel Walsh

Hi,


You can't since the same control refers to the field Make and to the field
Model. Without further instructions, Jet cannot proceed, it just do no know
how, it is not "evident", your need is just one among other possible ones.
So, we have to supply the instructions.


Do not bind a control to the computed field name, but "push" the value into
it (hide the control bound to "name"); in the onCurrent event:

me.UnboundControl = me.Controls("Name")




In the before update event of the form, supply the logic to update the two
individual fields:


i = InStr( Me.UnboundControl & " " , " " ) -1
Me.Make = Left(Me.UnboundControl, i )
Me.Model= Mid( Me.UnboundControl, i+1)



and, change the SELECT statement to add Make and Model available, alone.
(Add and hide the controls Make and Model)



Hoping it may help,
Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top