Default Value

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

Guest

Is there a way to set the default value as a look up value? I have two
tables, one is static that lists people and their suggested skill level. The
second is a task assignment table which lists names and the skill level
they'd work on. When I add a task code and enter someone's name, I want the
field that lists the level to fill in with his suggested skill level from the
first table.

Is this possible?

Appreciate any help you can provide!
 
You would not set the DefaultValue property for this; that puts a value in a
field when a new record is added, so the value would be put in before the
task code was known. In your case, when adding a record in a form you can
look up the skill level and insert it into the relevant control on the form.
I assume that, as you refer to 'default value', you want to be able to change
the value inserted if necessary. In that case you'd put some code in the
task code control's AfterUpdate event procedure which looks up the skill
level from the People table and assigns it to the skill level control n the
form, e.g. if the task code is a number data type:

Me.[SkillLevel] = DLookup("[SkillLevel]", "[People]", "[TaskCode] = " &
Me.[TaskCode]

Or if it’s a text data type:

Me.[SkillLevel] = DLookup("[SkillLevel]", "[People]", "[TaskCode] = """ &
Me.[TaskCode] & """"

You can't do this when entering data directly in a table in datasheet view,
but in any application worth its salt data should always be entered/edited
via forms.

Ken Sheridan
Stafford, England
 
Back
Top