Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populating a field without using combo box

Status
Not open for further replies.

Griff389

Technical User
Jun 27, 2003
82
GB
I've got a form with two controls in particular called txtProduct and txtDescription. I have a separate tblProducts table which holds the products and descriptions.

When a user types in a prodcut code in the txtProduct box how can I get it to put the corresponding description from the table in the txtDescription box?

I can do it using a combo box to query the tbkProducts table and then populate the description depending on what they choose, but I don't want to do it that way as the users keep changing the data in the combo box thinking it's a 'lookup' field and don't realise they are changing the data.

Regards

Griff
 
Place this code in the LostFocus event of txtProduct.

me.txtDescription = DLookup("Description", "tblProducts", "ProdCode = " & me.txtProduct)



Randy
 
Thanks for that. The above gave me a couple of problems, but finally got it working using the Dlookup as you said.

Code:
Me.txtDescription = Trim(DLookup("[DESC]", "Uk2", "[PRODUCT] = '" & Me.txtProduct & "'"))

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top