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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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,
 
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 )
 
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 said:
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 said:
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,
 
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 said:
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 said:
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 said:
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,
 
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 said:
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 said:
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 said:
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

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,
 
prototype said:
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 said:
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 said:
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 said:
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.

:

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

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,
 
Back
Top