Data entry

G

Guest

I have the Table
ID Autonumeric
CodFarmer String
CodSemester Lookup (String)
CodAnimal Lookup (String)
Quantity Numeric
AnimalUnit Numeric

AnimalUnit must have the values indicated below:
CodAnimal Animal Unit
1 1
2 1
3 1
4 0.25
5 0.5
6 0.75
7 1.25
8 1
9 0.75
10 0.5
11 1.25
12 1
13 1


I would like to be able that when I select a value in CodAnimal the
respective value in AnimalUnit field will be filled. How can I do this?

Many thansk
 
M

Marshall Barton

sebastico said:
I have the Table
ID Autonumeric
CodFarmer String
CodSemester Lookup (String)
CodAnimal Lookup (String)
Quantity Numeric
AnimalUnit Numeric

AnimalUnit must have the values indicated below:
CodAnimal Animal Unit
1 1
2 1
3 1
4 0.25
5 0.5
6 0.75
7 1.25
8 1
9 0.75
10 0.5
11 1.25
12 1
13 1


I would like to be able that when I select a value in CodAnimal the
respective value in AnimalUnit field will be filled. How can I do this?


Make sure both fields are included in the combo box's
RowSource query. Set the corresponding column width to 0 if
you don't want to see it in the drop down list.

The set the AnimalUnit text box control source expression
to:
=thecombobox.Column(1)
 
G

Guest

Dear Marshall

Many thanks for your spedy reply,
Unfortunately I am not so skillful in Access. Could you explain in more
details whayt I have to do? Do I have to do a Query, how? Where do I have to
write the code?

Thanks again
 
M

Marshall Barton

I presume that you have a table with the CodAnimal and
Animal Unit values that you posted. Use that table as the
RowSource of the CodAnimal combo box on your form.

The expression I posted is not code. Double click on the
form's Animal Unit text box to display its property sheet
and enter the expression in the Control Source property.
 
G

Guest

I did what you suggest. That means when entering data I have to select both
values (inCodAnimal and AnimalUnit) in the form . Is that correct?
But in order to avoid mistakes when typing my idea is that when I select a
CodAnimal value the computer fills the respective AnimalUnit value.

Once again many thanks


Marshall Barton said:
I presume that you have a table with the CodAnimal and
Animal Unit values that you posted. Use that table as the
RowSource of the CodAnimal combo box on your form.

The expression I posted is not code. Double click on the
form's Animal Unit text box to display its property sheet
and enter the expression in the Control Source property.
--
Marsh
MVP [MS Access]

Many thanks for your spedy reply,
Unfortunately I am not so skillful in Access. Could you explain in more
details whayt I have to do? Do I have to do a Query, how? Where do I have to
write the code?
 
M

Marshall Barton

No, that's not the what I mean. The combo box is used to
select the CodAnimal. The text box will then automatically
display the AnimalUnit value.

Can you try what I suggested and report back with what about
it doesn't meet your needs?
 
G

Guest

Dear Marshall

According your advice in my Table the CodAnimal (Lookup) Field design is

Col1 Col2
1 1.0
2 1.0
3 1.0
4 0.25
5 0.50
6 0.75
7 0.25
8 1.0
9 0.75
10 0.50
11 1.25
12 1.0
13 1.0

In the form I dragged the combo box with the above columns. Then I dragged
the Textbox and after double clicking I entered the expression
=thecombobox.Column(1) in the control Source property. Nevertheless once the
form is open the Textbox displays #Name?

Marshall Barton said:
No, that's not the what I mean. The combo box is used to
select the CodAnimal. The text box will then automatically
display the AnimalUnit value.

Can you try what I suggested and report back with what about
it doesn't meet your needs?
--
Marsh
MVP [MS Access]

I did what you suggest. That means when entering data I have to select both
values (inCodAnimal and AnimalUnit) in the form . Is that correct?
But in order to avoid mistakes when typing my idea is that when I select a
CodAnimal value the computer fills the respective AnimalUnit value.
 
M

Marshall Barton

You were supposed to replace "thecombobox" with the actual
name of your combo box (CodAnimal?). If you don't know how
to find out what the combo box is named, just double click
on it and the properties sheet will tell you its name in
both the title bar and in the Name property.
 
G

Guest

Marshall
Correct As you said now the form dispalys the true AnimalUnit value but the
table displays 0.00. I don't know how to fix this.

Many thanks

Marshall Barton said:
You were supposed to replace "thecombobox" with the actual
name of your combo box (CodAnimal?). If you don't know how
to find out what the combo box is named, just double click
on it and the properties sheet will tell you its name in
both the title bar and in the Name property.
--
Marsh
MVP [MS Access]

According your advice in my Table the CodAnimal (Lookup) Field design is

Col1 Col2
1 1.0
2 1.0
3 1.0
4 0.25
5 0.50
6 0.75
7 0.25
8 1.0
9 0.75
10 0.50
11 1.25
12 1.0
13 1.0

In the form I dragged the combo box with the above columns. Then I dragged
the Textbox and after double clicking I entered the expression
=thecombobox.Column(1) in the control Source property. Nevertheless once the
form is open the Textbox displays #Name?
 
M

Marshall Barton

What table? Are you trying to save both the CodAnimal and
the AnimalUnit values to the form's record source table? If
so, wouldn't that be redundant? You should be able to get
the AnimalUnit value in any query by Joining to the lookup
table on the CodAnimal field.

Or do the AnimalUnit values change over time and you need
the value that was in effect when the record was created
(like the price on an order)? If this is the case, instead
of using the text box's control source expression, you need
to use code in the CodAnimal(?) combo box's AfterUpdate
event:
Me.AnimalUnit = Me.CodAnimal.Column(1)
--
Marsh
MVP [MS Access]


sebastico wrote
 
G

Guest

Marshall
I try what you suggested, nevertheless, when I click the combo box Access
displays the message: The field is to small to accept the amount of data you
attempted to add. Try inserting or pasting less data.
What can I do?

Thanks for your help.

Marshall Barton said:
No, that's not the what I mean. The combo box is used to
select the CodAnimal. The text box will then automatically
display the AnimalUnit value.

Can you try what I suggested and report back with what about
it doesn't meet your needs?
--
Marsh
MVP [MS Access]

I did what you suggest. That means when entering data I have to select both
values (inCodAnimal and AnimalUnit) in the form . Is that correct?
But in order to avoid mistakes when typing my idea is that when I select a
CodAnimal value the computer fills the respective AnimalUnit value.
 
G

Guest

Marshall

Tnak you very much indeed again finally I was able tu use the code you
suggested.

Marshall Barton said:
What table? Are you trying to save both the CodAnimal and
the AnimalUnit values to the form's record source table? If
so, wouldn't that be redundant? You should be able to get
the AnimalUnit value in any query by Joining to the lookup
table on the CodAnimal field.

Or do the AnimalUnit values change over time and you need
the value that was in effect when the record was created
(like the price on an order)? If this is the case, instead
of using the text box's control source expression, you need
to use code in the CodAnimal(?) combo box's AfterUpdate
event:
Me.AnimalUnit = Me.CodAnimal.Column(1)
--
Marsh
MVP [MS Access]


sebastico wrote
Correct As you said now the form dispalys the true AnimalUnit value but the
table displays 0.00. I don't know how to fix 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

Top