"prototype" wrote:
> Is it possible to bind a text box to a field similar to how one binds a form
> to a recordset in VBA? Something like this...
>
> dim rst as adodb.recordset
> set rst = new adodb.recordset
> rst.open .........
> textBoxName.countrolsource = rst.fields(1)
No, sorry, I'm afraid a control can be bound only to a field in the form's
recordset, not one in another recordset.
But if you have opened the other recordset and assigned it to a module-level
variable in your form's class module, then you can use the unbound textbox
idea and update the recordset field in the textbox's AfterUpdate event.
--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand
[please reply only to the newsgroup]
"prototype" wrote:
> Is it possible to bind a text box to a field similar to how one binds a form
> to a recordset in VBA? Something like this...
>
> dim rst as adodb.recordset
> set rst = new adodb.recordset
> rst.open .........
> textBoxName.countrolsource = rst.fields(1)
>
> Thanks for all your help.
>
> "Graham Mandeno" wrote:
>
> > OK, I don't think there's any was you could use a bound textbox except, as
> > you say, in a subform.
> >
> > However, you might find it easier to use an unbound textbox. Load the value
> > with a DLookup in the Form_Load event, and then execute a SQL UPDATE
> > statement in the AfterUpdate event of the textbox:
> >
> > CurrentDb.Execute "Update TableName Set FieldName='" & TextboxName & "'';"
> >
> > --
> > Good Luck :-)
> >
> > Graham Mandeno [Access MVP]
> > Auckland, New Zealand
> >
> > "prototype" <(E-Mail Removed)> wrote in message
> > news:F46DF56A-28DD-4CB1-98AE-(E-Mail Removed)...
> > > The tables are not related so I can not join them in a query.
> > > Unfortunatly,
> > > if I use DLookup in the control source of the text box as suggested then
> > > the
> > > user can not modify the value in the Text Box. I guess I could create a
> > > sub
> > > form to do what I need but I thought there might be an easier way. I was
> > > hoping that there was a way to just bind the text box to another table.
> > > That
> > > would be great.
> > >
> > > Thanks for the quick response and all your help. I really apreciate it.
> > >
> > > "Graham Mandeno" wrote:
> > >
> > >> Is there a relationship between the two tables? If so, then create a
> > >> query
> > >> based on BOTH the tables, joined on the related fields and you can
> > >> include
> > >> fields from both tables in your query. Base the form's recordsource on
> > >> the
> > >> query, not the original table.
> > >>
> > >> If the tables are not related, you can use an expression involving the
> > >> DLookup function in the controlsource of the textbox.
> > >>
> > >> =DLookup( "FieldName", "TableName", optional-selection-criteria )
> > >>
> > >> --
> > >> Good Luck :-)
> > >>
> > >> Graham Mandeno [Access MVP]
> > >> Auckland, New Zealand
> > >>
> > >> "prototype" <(E-Mail Removed)> wrote in message
> > >> news:10423EBE-A091-4DC8-955C-(E-Mail Removed)...
> > >> >I am trying to bind a text box to a table. However, the table I need to
> > >> >bind
> > >> > it to is not the same as the on in the Form's record source. Is there
> > >> > an
> > >> > easy
> > >> > way to do this?
> > >> >
> > >> > I tried to bind it by typing the following in the Text Box controll
> > >> > source
> > >> > but I got an error:
> > >> >
> > >> > tableName!fieldName
> > >> >
> > >> > Is there an easy way to do this?
> > >> >
> > >> > Thanks,
> > >>
> > >>
> >
> >
> >
|