ControlSource

  • Thread starter Thread starter Patrick McGuire
  • Start date Start date
P

Patrick McGuire

Is it possible to bind a textbox to a field in a
recordset? Failing that, how do I bind to a SQL string?
The help says it's possible, but I can't seem to figure
out the correct format for doing it. Thanks.

Pat
 
Yes, you can bind the control to a recordset by setting
the control's controlsource property. This binds the
data that the user inputs to the underlying table.

Jen
 
Hmm. How is this done? For example, I have a
DAO.Recordset object called rst that contains a field
object, fld. How do I set the ControlSource of a textbox
named txt1 to fld1? In vba saying, for
example "txt1.ControlSource=rst(fld1.name)" doesn't work;
it just set txt1 equal to the contents of fld1, but
doesn't let the user edit those contents.

Pat
 
Patrick said:
Is it possible to bind a textbox to a field in a
recordset? Failing that, how do I bind to a SQL string?
The help says it's possible, but I can't seem to figure
out the correct format for doing it.


No, not to a recordset field. There is no way Access could
synchronize the form's current record to the appropriate(??)
record in the recordset.

You can not bind a control to an SQL statement either. The
only thing a control can be bound to is a field in the
form/report's record source.

You'll have to handle it as an unbound control. Use VBA (in
the form's Current event) to set it's value and use the
control's AfterUpdate event to keep track of user entered
values so you can update the recordset.
 
Cheers Marsh,

I had pretty much come to that same conclusion myself.
Bummer.

Pat
 
Back
Top