Fetch specific value from table

enigma54

Registered User.
Local time
Today, 16:06
Joined
Feb 19, 2010
Messages
25
Hi,

I am trying to acomplish the following using VB (rather unsuccessfully at present I might add!)

I have a combobox on a form that fetches values from the 'SalesCode' field of a lookup table. This lookup table also contains a 'Description' field. What I am after is when I select a value from the SalesCode combobox for it to return the appropriate description to a text box on the same form.

I have attached a much slimmed down copy of the database with only the fields in question.

I had originally tried to use a =dlookup on the after update event of the combobox but this only ever returned the first description in the lookup table regardless of the value in the combobox

I would very much appreciate any help with this.

Thanks

Dave

View attachment Converted.mdb
 
Change the SQL for the combo to

Code:
SELECT SalesCode, Description
FROM TblSalesCodeLookup
ORDER BY SalesCode;

Go to ther properties of the combo

Column Count = 2
Column widths 3cm,0cm
Bound Column = 1

Then on the after update event of the combo

Me.TxtDescription = Me.Combo.Column(1)

Don't forget that columns are zero based.

Filed names and control names used are for brevity only.
 
Elegantly simple! Thank you very much for this :-)

Dave
 

Users who are viewing this thread

Back
Top Bottom