Assuming your input variable are correct
EDesig -> Table/Query field name
EmpNewQ1 -> Table/Query to search through
ECode -> Table/Query field name to filter on
Me.SlEDesig = DLookup("[EDesig]", "[EmpNewQ1]",
will not work! You cannot encase your form value within Quotes.
Me.SlEDesig = DLookup("[EDesig]", "[EmpNewQ1]", "[ECode]='" &
Forms![SlFormA]![SlEcode] & "'")
Should work, but I do have a question. What type of value/data type is
Forms![SlFormA]![SlEcode]? (text, number, ...) If it is a number then you would
have to use
Me.SlEDesig = DLookup("[EDesig]", "[EmpNewQ1]", "[ECode]=" &
Forms![SlFormA]![SlEcode])
The easiest way to work/test Dlookup or any function for that matter is to
test your commands in the vba immediate window. Once you have the proper
synthax working there, then it will be relatively easy to switch it completly
to VBA.
You may also wish to use the Nz() to deal with Null values, etc. in case
DLookUp does not return any values...
Nz(DLookUp(...),"YourDefaultValue")
--
Hope this helps,
Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.