Automatically get Value from a table based on values entered on fo

P

PPCO

I have 4 fields on a form: [Activityname], [Itemname], [UOM], and
[Equipmentname]. I would like to create a text or combo box that based on
what the user enters in those 4 fields, automatically populates a field from
a separate table called [tblgoalbyequipment].[goallevel]. I see numerous posts
on here that would seem to answer the question, but not having much luck.
Thanks!
 
D

Duane Hookom

Is that all you are willing to tell us?
How would you do this manually?
Can we assume there is more than one record in tblgoalbyequipment?
Do you want a random goallevel or one based on some logic that only you know?
Do you expect to simply display the value or do you have a good reason for
storing a value that can be calculated?
 
P

PPCO

Oops, sorry. In [tblgoallevel] there are related fields that match
[activityname], [itemname], [UOM], and [equipmentname]. There are multiple
records in that table. So when a user fills in the 4 fields above on the form
(which goes to [tblproduction], I wanted to put a field on the form that
would automatically populate with the related goal level from [tblgoallevel].
Hope that's more clear; thanks alot!

Duane Hookom said:
Is that all you are willing to tell us?
How would you do this manually?
Can we assume there is more than one record in tblgoalbyequipment?
Do you want a random goallevel or one based on some logic that only you know?
Do you expect to simply display the value or do you have a good reason for
storing a value that can be calculated?

--
Duane Hookom
Microsoft Access MVP


PPCO said:
I have 4 fields on a form: [Activityname], [Itemname], [UOM], and
[Equipmentname]. I would like to create a text or combo box that based on
what the user enters in those 4 fields, automatically populates a field from
a separate table called [tblgoalbyequipment].[goallevel]. I see numerous posts
on here that would seem to answer the question, but not having much luck.
Thanks!
 
D

Duane Hookom

I expect you would need code in the Before Update of the form something like:

Me.txtGoalLevel = DLookup("GoalLevel","tblGoalLevel","[ActivityName]='" & _
Me.txtActivityName & "' AND [ItemName]='" & Me.txtItemName & _
"' AND UOM = '" & Me.txtUOM & "' AND EquipmentName = '" &
Me.txtEquipName & "'")

This all depends on your exact field and control names as well as their data
types. The above code suggests all fields are text and that none of the text
values will include an apostrophe in them.
--
Duane Hookom
Microsoft Access MVP


PPCO said:
Oops, sorry. In [tblgoallevel] there are related fields that match
[activityname], [itemname], [UOM], and [equipmentname]. There are multiple
records in that table. So when a user fills in the 4 fields above on the form
(which goes to [tblproduction], I wanted to put a field on the form that
would automatically populate with the related goal level from [tblgoallevel].
Hope that's more clear; thanks alot!

Duane Hookom said:
Is that all you are willing to tell us?
How would you do this manually?
Can we assume there is more than one record in tblgoalbyequipment?
Do you want a random goallevel or one based on some logic that only you know?
Do you expect to simply display the value or do you have a good reason for
storing a value that can be calculated?

--
Duane Hookom
Microsoft Access MVP


PPCO said:
I have 4 fields on a form: [Activityname], [Itemname], [UOM], and
[Equipmentname]. I would like to create a text or combo box that based on
what the user enters in those 4 fields, automatically populates a field from
a separate table called [tblgoalbyequipment].[goallevel]. I see numerous posts
on here that would seem to answer the question, but not having much luck.
Thanks!
 

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