Auto Enter Data in Field from Table

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

Guest

I have a table with two fields one a number and the other a description. In
my form I would like to enter the number and have the description
automatically pull into the description on the form. How can I do this?
 
SG,

I take it that the form in question is based on a different table? Into
the Control Source property of the textbox, you could put the equivalent
of this...
=DLookup("[Description]","YourTable","[TheNumber]=" & [TheNumber])

If you are using a Combobox to enter TheNumber on the form, there is
another possibility. For discussion of a related topic, see
http://accesstips.datamanagementsolutions.biz/lookup.mht
 
Hi Steve,
Thank you for your reply. I think you are on the right track
I put the Dlookup in and I get #Error in the field.
I have a form with sub form for MOS Code and MOS Desc
I created a Table to Store all of the MOS Codes and descriptions
I created a subform and placed it in the mail form
I put a Combo box to choose which MOS Code I need and when I choose it have
the
description pull into the next field.
the reason for the subform is that each person has more that one MOS Code
and I can list as many as I need. I have 6 other subforms in the main form
with codes for Army, Navy, Marines, Degree, Certs etc.
Do you know why this is not working here is the exactly how I put it in the
control source =DLookUp("[MOS Code]","MOS Desc","[MOS Desc]='" & [MOS
Desc] & "'")
Steve Schapel said:
SG,

I take it that the form in question is based on a different table? Into
the Control Source property of the textbox, you could put the equivalent
of this...
=DLookup("[Description]","YourTable","[TheNumber]=" & [TheNumber])

If you are using a Combobox to enter TheNumber on the form, there is
another possibility. For discussion of a related topic, see
http://accesstips.datamanagementsolutions.biz/lookup.mht

--
Steve Schapel, Microsoft Access MVP

I have a table with two fields one a number and the other a description. In
my form I would like to enter the number and have the description
automatically pull into the description on the form. How can I do this?
 
SG,

In the table that the subform is based on, is there a 'MOS Desc' field?
There shouldn't be! The 'MOS Code' is all that goes in there, as the
"master list' of Codes and Descriptions will always be able to tell you
which Description is associated with the Code you have entered, exactly
like you are doing it. Make sense? Your expression would indicate that
'MOS Desc' is also the name of the table that is the 'master list' of
Codes and Descriptions, is this correct? Also, the textbox you are
entering this expression into its Control Source should not be named
'MOS Code' or 'MOS Desc', can you check this? And also, it seems to me
that you have the expression topsy-turvy. If I understand you
correctly, shouldn't it be like this?....
=DLookUp("[MOS Desc]","MOS Desc","[MOS Code]='" & [MOS Code] & "'")
.... or, if the Code is numerical, like this...
=DLookUp("[MOS Desc]","MOS Desc","[MOS Code]=" & [MOS Code])
 
Back
Top