POPULATING A TEXT BOX ON A FORM

G

Guest

As you can tell, I've fairly new to Access. I have a problem with a form.
I've tried everything I can think of, but I can't seem to get this to work.

On my form, I have a comb box that listes a variety of menu items, and this
is connected to my table (Menu). This part works great.

Next to the combo box, I have a text box called "Target weight". I want this
box to go to the Menu Table, find the menu item selected in the combo box,
then show the corresponding "target weight" for this menu item.

Here's what I'm showing in the Control Source Property for the text box:
"=Menu![Target Weight]". However, in the form, it shows the error message
"#Name?".

Then I tried to build a query that shows two columns from the Menu table,
the menu item and the target weight. That worked OK. so back to the form, I
set the control source property to the query, but it still shows the same
error.

Thanks for helping with this.
 
J

Joan Wild

Change the rowsource of your combobox to include both the 'menu item' and
the 'target weight'.
On the format tab..
Column Count: 2
Column Widths: 1;1

You can set the control source of your textbox to
=[Name of combobox control].[column](1)

An alternative, that doesn't require a textbox is to change the rowsource of
your combobox to something like
SELECT [menu item] & " - " & [target weight] AS Expr1, [menu item], [target
weight]
FROM [Menu]

Then change the bound column to 2 and the column widths to .0007;1;1 and the
column count to 3
 
G

Guest

Before you start working on the combo box, you need to get your form
presenting the data correctly. Whether you base your form on a table or a
query doesn't matter. You need to understand a couple of basics. First, a
text box is bound to a field in the form's recordsource. The recordsource is
a property of the form (the table or query). First, open your form in design
view. Click on properties and be sure the properties dialog says Form. Then
select the Data tab. In the Record Source select the table or query that
will be the underlying data for your form.
Now select a text box or other control. In the Data tab, select the field
in the table or query you want to present from the form's record source.

Using a combo box to look up a value in you table/query and make your form
display the selected record takes propert set up of the combo and some VBA
coding. After you get your form working correctly, post back with the
following info and I will show you how it is done:
Is the Combo bound or unbound (bound = has a control source)?
What is the Row Source type of your combo?
What is the Row Source of your combo?
How many columns are in the combo?
 
G

Guest

That did the trick. Thanks for your help.

Now, I ready to enter my data on the Form. It will let me enter the first
row of data, but when I get to the last field and either hit "Return" or
"tab", it stays in the last field and doesn't go to the next record. Any
clues?

Steve

Joan Wild said:
Change the rowsource of your combobox to include both the 'menu item' and
the 'target weight'.
On the format tab..
Column Count: 2
Column Widths: 1;1

You can set the control source of your textbox to
=[Name of combobox control].[column](1)

An alternative, that doesn't require a textbox is to change the rowsource of
your combobox to something like
SELECT [menu item] & " - " & [target weight] AS Expr1, [menu item], [target
weight]
FROM [Menu]

Then change the bound column to 2 and the column widths to .0007;1;1 and the
column count to 3


--
Joan Wild
Microsoft Access MVP
As you can tell, I've fairly new to Access. I have a problem with a
form. I've tried everything I can think of, but I can't seem to get
this to work.

On my form, I have a comb box that listes a variety of menu items,
and this is connected to my table (Menu). This part works great.

Next to the combo box, I have a text box called "Target weight". I
want this box to go to the Menu Table, find the menu item selected in
the combo box, then show the corresponding "target weight" for this
menu item.

Here's what I'm showing in the Control Source Property for the text
box: "=Menu![Target Weight]". However, in the form, it shows the
error message "#Name?".

Then I tried to build a query that shows two columns from the Menu
table, the menu item and the target weight. That worked OK. so back
to the form, I set the control source property to the query, but it
still shows the same error.

Thanks for helping with this.
 
J

Joan Wild

Check the cycle property of the form (in design view, bring up the
properties dialog; cycle is on the Other tab) - it needs to be All Records.

Check the recordsource of the form. Does it contain more than one record?
If it's a query is the query updateable? If you open the query, can you add
records there?


--
Joan Wild
Microsoft Access MVP
That did the trick. Thanks for your help.

Now, I ready to enter my data on the Form. It will let me enter the
first row of data, but when I get to the last field and either hit
"Return" or "tab", it stays in the last field and doesn't go to the
next record. Any clues?

Steve

Joan Wild said:
Change the rowsource of your combobox to include both the 'menu
item' and the 'target weight'.
On the format tab..
Column Count: 2
Column Widths: 1;1

You can set the control source of your textbox to
=[Name of combobox control].[column](1)

An alternative, that doesn't require a textbox is to change the
rowsource of your combobox to something like
SELECT [menu item] & " - " & [target weight] AS Expr1, [menu item],
[target weight]
FROM [Menu]

Then change the bound column to 2 and the column widths to .0007;1;1
and the column count to 3


--
Joan Wild
Microsoft Access MVP
As you can tell, I've fairly new to Access. I have a problem with a
form. I've tried everything I can think of, but I can't seem to get
this to work.

On my form, I have a comb box that listes a variety of menu items,
and this is connected to my table (Menu). This part works great.

Next to the combo box, I have a text box called "Target weight". I
want this box to go to the Menu Table, find the menu item selected
in the combo box, then show the corresponding "target weight" for
this menu item.

Here's what I'm showing in the Control Source Property for the text
box: "=Menu![Target Weight]". However, in the form, it shows the
error message "#Name?".

Then I tried to build a query that shows two columns from the Menu
table, the menu item and the target weight. That worked OK. so back
to the form, I set the control source property to the query, but it
still shows the same error.

Thanks for helping with this.
 
G

Guest

I would like to "piggyback" on this question. My form is called "Mediators"
and the fields are "Name" and "Work Phone Number". The form is based on a
table with the same name. What I am trying to do is have "Name" be a combo
box, and populate the text box "Work Phone Number" with the corresponding
phone number. If I choose Jack Sprat in "Name", then 555-1234 will show up
in the "Work Phone Number" text box.

Here's some info that might help you:
Is the Combo bound or unbound (bound = has a control source)? It is bound
What is the Row Source type of your combo? Table
What is the Row Source of your combo?
SELECT [Mediators].[Name], [Mediators].[Work Phone #] FROM Mediators;
How many columns are in the combo?
2

Thanks!

Klatuu said:
Before you start working on the combo box, you need to get your form
presenting the data correctly. Whether you base your form on a table or a
query doesn't matter. You need to understand a couple of basics. First, a
text box is bound to a field in the form's recordsource. The recordsource is
a property of the form (the table or query). First, open your form in design
view. Click on properties and be sure the properties dialog says Form. Then
select the Data tab. In the Record Source select the table or query that
will be the underlying data for your form.
Now select a text box or other control. In the Data tab, select the field
in the table or query you want to present from the form's record source.

Using a combo box to look up a value in you table/query and make your form
display the selected record takes propert set up of the combo and some VBA
coding. After you get your form working correctly, post back with the
following info and I will show you how it is done:
Is the Combo bound or unbound (bound = has a control source)?
What is the Row Source type of your combo?
What is the Row Source of your combo?
How many columns are in the combo?

scfosdick said:
As you can tell, I've fairly new to Access. I have a problem with a form.
I've tried everything I can think of, but I can't seem to get this to work.

On my form, I have a comb box that listes a variety of menu items, and this
is connected to my table (Menu). This part works great.

Next to the combo box, I have a text box called "Target weight". I want this
box to go to the Menu Table, find the menu item selected in the combo box,
then show the corresponding "target weight" for this menu item.

Here's what I'm showing in the Control Source Property for the text box:
"=Menu![Target Weight]". However, in the form, it shows the error message
"#Name?".

Then I tried to build a query that shows two columns from the Menu table,
the menu item and the target weight. That worked OK. so back to the form, I
set the control source property to the query, but it still shows the same
error.

Thanks for helping with this.
 

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

Similar Threads


Top