PC Review


Reply
Thread Tools Rate Thread

Bind a text box to a table that is not bound to the form.

 
 
=?Utf-8?B?cHJvdG90eXBl?=
Guest
Posts: n/a
 
      23rd May 2007
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,
 
Reply With Quote
 
 
 
 
Graham Mandeno
Guest
Posts: n/a
 
      23rd May 2007
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,



 
Reply With Quote
 
=?Utf-8?B?cHJvdG90eXBl?=
Guest
Posts: n/a
 
      23rd May 2007
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,

>
>

 
Reply With Quote
 
Graham Mandeno
Guest
Posts: n/a
 
      24th May 2007
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,

>>
>>



 
Reply With Quote
 
=?Utf-8?B?cHJvdG90eXBl?=
Guest
Posts: n/a
 
      24th May 2007
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,
> >>
> >>

>
>
>

 
Reply With Quote
 
=?Utf-8?B?R3JhaGFtIE1hbmRlbm8gW01WUF0=?=
Guest
Posts: n/a
 
      24th May 2007
"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,
> > >>
> > >>

> >
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bind form to more than one table XP Microsoft Access Form Coding 2 3rd Dec 2007 07:44 PM
Can I bind a text box on a form to a field in an open table =?Utf-8?B?Um9iZXJ0?= Microsoft Access Forms 0 2nd Mar 2006 07:55 PM
Bound Form needs field1 Average disp. by field1 Bound Text box website designer via AccessMonster.com Microsoft Access Form Coding 1 22nd Dec 2004 11:59 AM
How to bind a control on form to a different table than form is bound to? Mark Gonyea Microsoft Access Forms 2 7th Jun 2004 10:57 PM
How do I bind a control on a form to a different table than the form is bound to? Mark Gonyea Microsoft Access Forms 2 4th Jun 2004 09:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:50 AM.